错误膨胀类 android.widget.ImageButton [英] Error inflating class android.widget.ImageButton

查看:36
本文介绍了错误膨胀类 android.widget.ImageButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在系统/应用程序"上安装程序时出错.当我使用数据/应用程序"时,它运行良好.这是错误:

I have error when I install my programm on "system/app". When I use "data/app" it's working well. Here is error:

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 社区版 12.0.4.

I have no ideas, what's it can be. I use Android 2.3 and IntelliJ IDEA Community Edition 12.0.4.

推荐答案

在你的ImageButton需要替换

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

并添加到您的 Gradle 文件

and add to your Gradle file

defaultConfig {vectorDrawables.useSupportLibrary = true}

这篇关于错误膨胀类 android.widget.ImageButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆