Ok, it was a mistake. I have two themes.xml files, one for Honeycomb+, and one for Gingerbread-. I've only edited the file targeting Gingerbread-, and was testing on ICS... Sorry for the noise!
Le samedi 11 août 2012 12:50:26 UTC+2, Sébastien Brochet a écrit : > > Dear Android experts, > > I'm trying to set a ListView background color based on the current theme > attribute, but it crash every time the ListView is shown.It seems I'm doing > something wrong but I can't see what... > > Here's what I'm doing: > > First, create the background color: > > <resources> > <color name="userlist_background_light">#fff0f0f0</color> > <color name="userlist_background_dark">#ff040404</color> > </resources> > > > Second, create attributes for my custom themes: > > <resources> > <attr name="userlist_background" format="reference|color" /> > </resources> > > > Third, setting this attribute in my themes: > > <resources xmlns:android="http://schemas.android.com/apk/res/android"> > <style name="Light" parent="Theme.Sherlock.Light"> > <item > name="userlist_background">@color/userlist_background_light</item> > </style> > > <style name="Dark" parent="Theme.Sherlock"> > <item > name="userlist_background">@color/userlist_background_dark</item> > </style> > </resources> > > > And finally, using this attribute in the ListView xml: > > <ListView > android:id="@+id/user_bar" > android:layout_width="0dip" > android:layout_height="0dip" > android:background="?attr/userlist_background" > android:cacheColorHint="?userlist_background" > android:visibility="gone" /> > > > Even the Eclipse layout view crash. Of course, it works fine if I use a > "@color/" directly in the background attribute. It even work if I use say, > "?android:attr/colorBackground". The message error is: > > android.view.InflateException: Binary XML file line #8: Error inflating > class android.view.ListView > Caused by: android.content.res.Resources$NotFoundException: Resource is > not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010068 a=-1} > > I'm pretty sure I'm doing something wrong, as it works with android > attributes, but I haven't be able to find what during my Google searches. > > I hope you'll be able to help me! > > Many thanks, > > Sébastien. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

