使用引用的样式drawable时的致命异常

时间:2013-08-07 18:07:11

标签: android android-actionbar-compat

我正在使用新的支持v7库来处理新的actionbarcompat。

现在,我有基于主题的drawables,我通过attr引用。但是虽然drawables在那里并且属性被正确命名,并且每个样式我都引用了正确的drawable它仍然给了我这种致命的例外

08-07 21:01:13.675: E/AndroidRuntime(25341): FATAL EXCEPTION: main
08-07 21:01:13.675: E/AndroidRuntime(25341): android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at com.karriapps.tehilimlite.Tehilim$TehilimAdapter.getView(Tehilim.java:220)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.AbsListView.obtainView(AbsListView.java:2461)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1250)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.ListView.onMeasure(ListView.java:1162)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:639)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5056)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2361)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.View.measure(View.java:15473)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.Choreographer.doFrame(Choreographer.java:525)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.os.Handler.handleCallback(Handler.java:615)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.os.Looper.loop(Looper.java:137)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.app.ActivityThread.main(ActivityThread.java:4898)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at java.lang.reflect.Method.invokeNative(Native Method)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at java.lang.reflect.Method.invoke(Method.java:511)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at dalvik.system.NativeStart.main(Native Method)
08-07 21:01:13.675: E/AndroidRuntime(25341): Caused by: java.lang.reflect.InvocationTargetException
08-07 21:01:13.675: E/AndroidRuntime(25341):    at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 21:01:13.675: E/AndroidRuntime(25341):    ... 53 more
08-07 21:01:13.675: E/AndroidRuntime(25341): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01006f a=-1}
08-07 21:01:13.675: E/AndroidRuntime(25341):    at android

style.xml

    <style name="AppBaseThemeDark" parent="@style/Theme.AppCompat">
    <item name="windowActionBarOverlay">false</item>
    <item name="action_search_icon">@drawable/action_search_dark</item>
    <item name="action_about_icon">@drawable/action_about_dark</item>
    <item name="action_settings_icon">@drawable/action_settings_dark</item>
    <item name="action_help_icon">@drawable/action_help_dark</item>
    <item name="expand_icon">@drawable/expand_button_dark</item>
    <item name="action_favorite_icon">@drawable/favorite_button_dark</item>
    <item name="ic_launcher">@drawable/ic_launcher_dark</item>
    <item name="text_color">@android:color/white</item>
    <item name="side_background">@drawable/tiled_background_dark</item>

    <item name="actionBarItemBackground">@drawable/selectable_background_tehilim_dark</item>
    <item name="popupMenuStyle">@style/PopupMenu.Tehilim_dark</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Tehilim_dark</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Tehilim_dark</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Tehilim_dark</item>
    <item name="actionBarStyle">@style/ActionBar.Transparent.Tehilim_dark</item>
    <item name="actionModeBackground">@drawable/cab_background_top_tehilim_dark</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_tehilim_dark</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Tehilim_dark</item>        
</style>

attr.xml

<resources>
<attr name="action_search_icon" format="reference"/>
<attr name="action_about_icon" format="reference"/>
<attr name="action_help_icon" format="reference"/>
<attr name="action_settings_icon" format="reference"/>
<attr name="expand_icon" format="reference"/>
<attr name="action_favorite_icon" format="reference"/>
<attr name="ic_launcher" format="reference"/>
<attr name="text_color" format="reference"/>
<attr name="side_background" format="reference"/>
</resources>

和布局

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:id="@+id/title_layout"
    >    
<TextView 
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textColor="@color/titleColor"
    android:layout_alignParentLeft="true"
    android:padding="10dp"
    android:textSize="16sp"
    android:layout_centerVertical="true"
    android:text="@string/yehiTitle"
    />   

<ImageView 
    android:id="@+id/favorite"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="?attr/action_favorite_icon"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:contentDescription="@string/ok"
    android:padding="5dp"
    />

<ImageView
    android:id="@+id/expand"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_alignParentRight="true"
    android:contentDescription="@string/plus"
    android:src="?attr/expand_icon"
    android:padding="5dp"
    android:visibility="visible"
    />

</RelativeLayout>

<TextView 
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/title_layout"
    android:orientation="vertical"
    android:gravity="center"
    android:text="@string/yehiBefore"
    android:padding="10dp"
    android:textColor="?attr/text_color"
    />

</RelativeLayout>

编辑:添加了清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.karriapps.tehilimlite"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:supportsRtl="true"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher_frame"
        android:label="@string/app_name"
        android:name="com.karriapps.tehilimlite.utils.App"
        android:theme="@style/AppBaseTheme" >

        <activity
            android:name="com.karriapps.tehilimlite.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.karriapps.tehilimlite.utils.App" />
    </application>

</manifest>

如何解决?

0 个答案:

没有答案