为Android指定包路径:条目

时间:2010-05-24 07:25:24

标签: xml android preferences

我在android中的首选项页面中使用以下代码来显示项目列表。列表和值位于“app / res / xml / time.xml”

位置的文件中
 <ListPreference
           android:title="Time unit list"
           android:summary="Select the time unit"
           android:dependency="Main_Option"
           android:key="listPref"
           android:defaultValue="1"
           android:entries="?xml:time/timet"
           android:entryValues="@xml:time/timet_values" />

time.xml的代码如下:

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

我无法在我的首选项xml文件中引用这些值。 (上面的代码片段)。它给出了一个错误。如何为List首选项和entry_values

指定打包路径

感谢任何帮助。 干杯

1 个答案:

答案 0 :(得分:1)

您应该按名称引用string-array元素:

<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" />
相关问题