2013-06-13 151 views
2

我在「system/app」上安裝我的程序時出現錯誤。當我使用「數據/應用程序」時,它運行良好。 這裏是錯誤:膨脹類錯誤android.widget.ImageButton

android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageButton 
E/AndroidRuntime(2076): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622) 
E/AndroidRuntime(2076): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638) 
E/AndroidRuntime(2076): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
E/AndroidRuntime(2076): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928) 
E/AndroidRuntime(2076): at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime(2076): at android.os.Looper.loop(Looper.java:123) 
E/AndroidRuntime(2076): at android.app.ActivityThread.main(ActivityThread.java:3647) 
E/AndroidRuntime(2076): at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime(2076): at java.lang.reflect.Method.invoke(Method.java:507) 
E/AndroidRuntime(2076): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
E/AndroidRuntime(2076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
E/AndroidRuntime(2076): at dalvik.system.NativeStart.main(Native Method) 
E/AndroidRuntime(2076): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageButton 
E/AndroidRuntime(2076): at android.view.LayoutInflater.createView(LayoutInflater.java:518) 
E/AndroidRuntime(2076): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
E/AndroidRuntime(2076): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 
E/AndroidRuntime(2076): at android.app.Activity.setContentView(Activity.java:1657) 
E/AndroidRuntime(2076): at com.pniei.filemanager.Main.onCreate(Main.java:125) 
E/AndroidRuntime(2076): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
E/AndroidRuntime(2076): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586) 
E/AndroidRuntime(2076): ... 11 more 
E/AndroidRuntime(2076): Caused by: java.lang.reflect.InvocationTargetException 
E/AndroidRuntime(2076): at java.lang.reflect.Constructor.constructNative(Native Method) 
E/AndroidRuntime(2076): at java.lang.reflect.Constructor.newInstance(Constructor.java:415) 
E/AndroidRuntime(2076): at android.view.LayoutInflater.createView(LayoutInflater.java:505) 
E/AndroidRuntime(2076): ... 24 more 
E/AndroidRuntime(2076): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000e a=-1 r=0x7f02000e} 
E/AndroidRuntime(2076): at android.content.res.Resources.loadDrawable(Resources.java:1681) 
E/AndroidRuntime(2076): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
E/AndroidRuntime(2076): at android.widget.ImageView.<init>(ImageView.java:118) 
E/AndroidRuntime(2076): at android.widget.ImageButton.<init>(ImageButton.java:85) 
E/AndroidRuntime(2076): at android.widget.ImageButton.<init>(ImageButton.java:81) 
E/AndroidRuntime(2076): ... 27 more 

這裏是我的代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/offWhite"> 
    <HorizontalScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/offWhite" 
      android:gravity="center"> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="6dp" 
       android:layout_marginRight="2dp" 
       android:layout_marginTop="6dp" 
       android:src="@drawable/back" 
       android:id="@+id/back_button" /> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="6dp" 
       android:layout_marginRight="2dp" 
       android:layout_marginTop="6dp" 
       android:src="@drawable/device_access_sd_storage" 
       android:id="@+id/home_button"/> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="6dp" 
       android:layout_marginRight="2dp" 
       android:layout_marginTop="6dp" 
       android:src="@drawable/collections_view_as_list" 
       android:id="@+id/multiselect_button"/> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_gravity="center_vertical"> 
       <TextView 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:textColor="@color/black" 
         android:textSize="14dp" 
         android:id="@+id/storage_label"/> 
       <TextView 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:textColor="@color/black" 
         android:textSize="14dp" 
         android:text="путь" 
         android:id="@+id/path_label"/> 
       <TextView 
         android:id="@+id/detail_label" 
         android:textColor="@color/brightRed" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:textSize="14px" 
         android:gravity="center"/> 
       </LinearLayout> 

     </LinearLayout> 
    </HorizontalScrollView> 
</LinearLayout> 

我沒有任何想法,什麼是它可以。我使用Android 2.3和IntelliJ IDEA Community Edition 12.0.4。

+0

你在你的佈局使用'ImageButton'。但在您的代碼中,您可能正在使用ImageView或按鈕 –

+0

正確使用我的代碼。程序工作正確,當它在「數據/應用程序」,但當我把它移動到「系統/應用程序」我有這個錯誤。 –

+1

你有沒有得到這個解決方案? – andygeers

回答

0

您確定backdevice_access_sd_storagecollections_view_as_list都是您的可繪製文件夾中的png圖像嗎?它抱怨說一個或多個這些ID是無效的。

+0

是的。這是完全正確的。 –

0

在上面的xmlfile我沒有找到xmlns:tools="http://schemas.android.com/tools"你的根佈局,如果不嘗試添加這一行。

+1

在LinearLayout中?我試過了,但它不能解決我的問題。 –

0

在你ImageButton需要更換

android:src="@drawable/back"app:srcCompat="@drawable/back"

,並添加到您的搖籃文件

defaultConfig { vectorDrawables.useSupportLibrary = true }

相關問題