Android ListPreference默认值问题

时间:2017-05-08 19:13:55

标签: android

我创建了listpreference以选择值,但是当我想设置默认值时,它表示无法解析符号' Radio1'。

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:title="Settings">

        <ListPreference
            android:title="Select radio station"
            android:key="station"
            android:summary="Select radio station you want to listen"
            android:defaultValue="Radio1"
            android:entries="@array/radio_stations"
            android:entryValues="@array/radio_stations"
            android:icon="@drawable/ic_radio_white_48dp">
        </ListPreference>

    </PreferenceCategory>
</PreferenceScreen>

arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string-array name="radio_stations">
        <item>Radio1</item>
        <item>Radio2</item>
        <item>Radio3</item>
        <item>Radio4</item>
    </string-array>

</resources>

0 个答案:

没有答案