I've run into an odd bug that only occurs on API9 and API10 devices.  On 
API8 devices, my code works as expected.  Let me lay the groundwork:

I have a Preferences Activity and I want the look of it to be similar to the 
rest of my application, so I apply a theme, based on Theme.Light.

Here's my Preferences:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android";
    android:title="@string/settings_title">
    <PreferenceCategory
        android:title="@string/heading_user_prefs">
        <EditTextPreference 
            android:title="@string/label_emailAddress"
            android:summary="@string/not_set"
            android:key="@string/key_emailAddress"
            android:capitalize="none"
            android:inputType="textEmailAddress"
            android:singleLine="true" />
    </PreferenceCategory>
    <PreferenceCategory
        android:title="@string/heding_misc_options">
        <CheckBoxPreference
            android:title="@string/label_option1"
            android:summaryOn="@string/summary_option1_enabled"
            android:summaryOff="@string/summary_option1_disabled"
            android:key="@string/key_option1"
            android:defaultValue="false" />
    </PreferenceCategory>
</PreferenceScreen>

Here's my Theme:
<style name="MyTheme" parent="@android:style/Theme.Light">
    <item 
name="android:windowTitleBackgroundStyle">@style/MyWindowTitle</item>
    <item 
name="android:listSeparatorTextViewStyle">@style/MyPreferenceCategory</item>
</style>

My theme was working find until I added the last item - the 
listSeparatorTextViewStyle.  Here's the definition of that:
<style name="MyPreferenceCategory" 
parent="@android:style/Widget.TextView.ListSeparator.White">
    <item name="android:background">@drawable/my_category_bg</item>
</style>

Now, on Android 2.2 (API8) devices, this works as expected.  When I load my 
Preferences Activity, I get the look I expect.  On API9/10 devices I get the 
classic Force Close:

ERROR/AndroidRuntime(3145): FATAL EXCEPTION: main
ERROR/AndroidRuntime(3145): java.lang.RuntimeException: Binary XML file line 
#18: You must supply a layout_width attribute.
ERROR/AndroidRuntime(3145):     at 
android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
ERROR/AndroidRuntime(3145):     at 
android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3598)
ERROR/AndroidRuntime(3145):     at 
android.view.ViewGroup$LayoutParams.<init>(ViewGroup.java:3551)
ERROR/AndroidRuntime(3145):     at 
android.widget.AbsListView$LayoutParams.<init>(AbsListView.java:4314)
ERROR/AndroidRuntime(3145):     at 
android.widget.AbsListView.generateLayoutParams(AbsListView.java:4108)
ERROR/AndroidRuntime(3145):     at 
android.widget.AbsListView.generateLayoutParams(AbsListView.java:74)
ERROR/AndroidRuntime(3145):     at 
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
ERROR/AndroidRuntime(3145):     at 
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
ERROR/AndroidRuntime(3145):     at 
android.preference.Preference.onCreateView(Preference.java:412)
ERROR/AndroidRuntime(3145):     at 
android.preference.Preference.getView(Preference.java:389)
ERROR/AndroidRuntime(3145):     at 
android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221)

Clearly the Binary XML file is not mine, since it's a PreferenceActivity.

It mentions a layout_width attribute is missing, so for kicks I declare 
one.  When I run it again, I get a FC complaining that it's missing a 
layout_width attribute.  I supply that and the Preference come up, but the 
text is not the right color.

As a test, I simply copied all the inherited attributes to my style and is 
displays normally.  So, as a workaround, for now, I created a values-v9 dir 
with this special styles.xml file in it.

It appears that nothing is getting inherited from the parent style: 
Widget.TextView.ListSeparator.White.  Why is that?  What changed in API9 
that's causing parent attributes to not get inherited?

As for my build environment, I'm using:
Android SDK Tools: r10
Android SDK Platform-tools: r3
Building against SDK Platform Android 2.2, API8: r2
Oracle JDK 1.6.0_24

Is this a bug and I should open a report, or did something change in API9 
that I'm unaware of?

Thanks,
- Rick Alther

-- 
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

Reply via email to