在扩展com.viewpagerindicator.TabPageIndicator时,异常“资源不是可绘制的”

时间:2014-05-13 16:53:32

标签: android viewpagerindicator

在Android 4.4.2和4.1.1上测试我的应用程序。设备我遇到了异常。 在给Jack Wharton ViewPagerIndicator充气的同时提出了例外。

logcat的

05-12 05:46:46.990: E/AndroidRuntime(1415): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.viewpagerindicator.TabPageIndicator
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater._createView(LayoutInflater.java:305)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater.onCreateView(LayoutInflater.java:509)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater.createViewFromTag(LayoutInflater.java:359)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater.rInflate(LayoutInflater.java:647)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:465)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:415)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.support.v4.app._HoloActivity.requestDecorView(_HoloActivity.java:381)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.support.v4.app._HoloActivity.setContentView(_HoloActivity.java:414)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at myproject.ActivityFavorites.onCreate(ActivityFavorites.java:94)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.app.Activity.performCreate(Activity.java:5231)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-12 05:46:46.990: E/AndroidRuntime(1415):     ... 11 more
05-12 05:46:46.990: E/AndroidRuntime(1415): Caused by: java.lang.reflect.InvocationTargetException
05-12 05:46:46.990: E/AndroidRuntime(1415):     at java.lang.reflect.Constructor.constructNative(Native Method)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at org.holoeverywhere.LayoutInflater._createView(LayoutInflater.java:281)
05-12 05:46:46.990: E/AndroidRuntime(1415):     ... 22 more
05-12 05:46:46.990: E/AndroidRuntime(1415): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01001c a=2}
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.content.res.Resources.loadDrawable(Resources.java:2068)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at com.viewpagerindicator.IcsLinearLayout.<init>(IcsLinearLayout.java:38)
05-12 05:46:46.990: E/AndroidRuntime(1415):     at com.viewpagerindicator.TabPageIndicator.<init>(TabPageIndicator.java:85)
05-12 05:46:46.990: E/AndroidRuntime(1415):     ... 25 more

据我所知,问题是id为0x7f01001c的资源。 在库中的ViewPagerIndicator,文件夹gen是一个文件R.java。在该文件中有代码片段:

GEN / COM-viewpagerindicator / R.java

public static final class attr {
    …
    public static int subtitle=0x7f01001c;
    …
}

bin / res / R.txt内部是一行:

int attr subtitle 0x7f01001c

在我的项目文件gen / myproject / R.java中:

public static final class attr {
    …
    /**  Custom divider drawable to use for elements in the action bar. 
         <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
         or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
    */
    public static final int actionBarDivider=0x7f01001c;
    …
}

在我的项目文件gen / com / viewpagerindicator / R.java中:

public static final class attr {
    public static final int actionBarDivider = 0x7f01001c;
    …
}

在我的项目文件gen / org.holoeverywhere / R.java

public static final class attr {
    public static final int actionBarDivider = 0x7f01001c;
    …
}

在bin / res / R.txt中的项目中有一行: int attr actionBarDivider 0x7f01001c 凭直觉,这似乎比副标题更好。

那么,这里有什么?正确的drawable将是我假设actionBarDivider。为什么选错了?为什么不会发生旧版本的Android?我该如何解决这个问题?

该应用程序已经过测试,适用于版本:2.3.5,2.3.6。

EDIT 根据要求,我包括布局XML

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

     <com.viewpagerindicator.TabPageIndicator
        android:id="@+id/viewPagerIndicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

     <ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

0 个答案:

没有答案