Specifiy package path for Android:entries
I am using following code in preferences page in android to show a list of items. The list and values are located in a file at location "app/res/xml/time.xml"
<ListPreference
android:title="Time unit list"
android:summary="Select the time unit"
android:dependency="Main_Option"
android:key="listPref开发者_Go百科"
android:defaultValue="1"
android:entries="?xml:time/timet"
android:entryValues="@xml:time/timet_values" />
The code for the time.xml is as follow:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="timet">
<item>seconds</item>
<item>minutes</item>
<item>hours</item>
</string-array>
<string-array name="timet_values">
<item>3600</item>
<item>60</item>
<item>1</item>
</string-array>
</resources>
I am not able to reference these values in my preference xml file. (The code snippet above). It gives an error. How can I specify packaged path for the List preferences entry and entry_values
Any help is appreciated. Cheers
You should references the string-array
elements by name:
<ListPreference
android:title="Time unit list"
android:summary="Select the time unit"
android:dependency="Main_Option"
android:key="listPref"
android:defaultValue="1"
android:entries="@array/timet"
android:entryValues="@array/timet_values" />
精彩评论