I can't understand from the Preferences and ListPreference documents
whether the defaultValue attribute in preferences.xml should be the
text choice displayed in the list, the Integer corresponding to that
choice, or the index of the choice. It also seems like best practice
to pick up the default value from the keys in arrays.xml rather than
put in a literal string. Can someone spell out how it should work?

Here's my arrays.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="tempUnitsNames"><item>Celsius</item>
<item>Fahrenheit</item>
</string-array>
<integer-array name="tempUnitsInts"><item>1</item>
<item>2</item>
</integer-array>
</resources>

Here's the relevant section of preferences.xml without a defaultValue
set.

<ListPreference android:entryValues="@array/tempUnitsInts"
android:entries="@array/tempUnitsNames" android:title="Units"
android:key="TempUnits" android:summary="Temperature Units"
android:persistent="true"></ListPreference>

Suppose I want the default choice to be Fahrenheit. What should be the
value of defaultValue?

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to