Setting the app:background attribute causes a crash (API <16)
Closed this issue · 2 comments
When I set the app:background
attribute on a page indicator (following the sample package)
<com.viewpagerindicator.UnderlinePageIndicator
android:id="@+id/indicator"
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#FFCCCCCC"
app:selectedColor="#FFCC0000"
/>
it works fine on Jelly Bean but on pre-4.1 devices that don't implement the View.setBackground(Drawable)
method it causes a crash:
A/dalvikvm(13919): Exception!!! threadid=1: thread exiting with uncaught exception (group=0x4001d858)
E/AndroidRuntime(13919): FATAL EXCEPTION: main
E/AndroidRuntime(13919): java.lang.RuntimeException: Unable to start activity ComponentInfo{package/class}: android.view.InflateException: Binary XML file line #30: Error > inflating class com.viewpagerindicator.UnderlinePageIndicator
...
E/AndroidRuntime(13919): Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.viewpagerindicator.UnderlinePageIndicator
...
E/AndroidRuntime(13919): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime(13919): at com.viewpagerindicator.UnderlinePageIndicator.(UnderlinePageIndicator.java:78)
...
E/AndroidRuntime(13919): Caused by: java.lang.NoSuchMethodError: com.viewpagerindicator.UnderlinePageIndicator.setBackground
E/AndroidRuntime(13919): at com.viewpagerindicator.UnderlinePageIndicator.(UnderlinePageIndicator.java:103)
Sample app downloaded from the Google Play works ok even on my 2.2 device but when I compile the sample package myself, it crashes.
Did something change?
(latest version 65 / 2.4.1)
UnderlinePageIndicator calls View#setBackgroundDrawable
on line 103, not View#setBackground
. Did you change something?
Oh, you're right, it does in the original! In mine it was setBackground
. I've changed it back and it is marked as deprecated. So either some form of autocorrect or I did it and don't remember it.
That should fix it, sorry for this and thanks for your time!