Okay, I think this probably isn't a bug in the preferences now, but
I'm still a little in the dark.

One issue is that (as far as I can tell) the array resource type isn't
documented, at least it doesn't appear in:
http://code.google.com/android/reference/available-resources.html

Looking at the ApiDemos I see that <string-array> elements are
supported, in addition to plain <array> elements; a little
investigation showed that <integer-array> elements are also supported.

Changing the <array> to <string-array> seems to fix the problem. But
it's not documented that this required. I'm left guessing that array
resources defined with an <array> element are automatically coerced
into types in a way that causes ListPreference instances to fail.

Tom.

On Sep 19, 11:57 pm, tomgibara <[EMAIL PROTECTED]> wrote:
> This is probably a bug in the Preferences framework, but I'm not
> particularly familiar with the API and the documentation is a little
> sparse, so I thought I'd check first...
>
> Is there a restriction on the strings that can be used in the
> entryValues array for a ListPreference?
>
> I define the following two arrays:
>
>     <array name="pref_delay_entries">
>         <item>30 minutes</item>
>         <item>1 hour</item>
>         <item>2 hours</item>
>         <item>4 hours</item>
>         <item>12 hours</item>
>         <item>day</item>
>     </array>
>
>     <array name="pref_delay_values">
>         <item>1800000</item>
>         <item>3600000</item>
>         <item>7200000</item>
>         <item>14400000</item>
>         <item>43200000</item>
>         <item>86400000</item>
>     </array>
>
> For use in the following ListPreference:
>
> <ListPreference
>     android:key="delay"
>     android:defaultValue="3600000"
>     android:title="@string/pref_delay_title"
>     android:summary="@string/pref_delay_summary"
>     android:entries="@array/pref_delay_entries"
>     android:entryValues="@array/pref_delay_values"
>     android:dialogTitle="@string/pref_delay_dialog_title"
>     />
>
> That's it, very simple. Running my PreferenceActivity and attempting
> to open the dialog (SDK 0.9 beta) results in the following exception:
>
> java.lang.NullPointerException
> at
> android.preference.ListPreference.findIndexOfValue(ListPreference.java:
> 169)
> at android.preference.ListPreference.getValueIndex(ListPreference.java:
> 178)
> at
> android.preference.ListPreference.onPrepareDialogBuilder(ListPreference.jav a:
> 190)
> at
> android.preference.DialogPreference.showDialog(DialogPreference.java:
> 289)
> at android.preference.DialogPreference.onClick(DialogPreference.java:
> 260)
> at android.preference.Preference.performClick(Preference.java:804)
> at
> android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:
> 182)
> ...
>
> Changing the elements of the pref_delay_values to something other than
> numbers removes the exception.
--~--~---------~--~----~------------~-------~--~----~
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