如何在Android中使用带开关的ListPreference?
我有一个prefs.xml文件如何在Android中使用带开关的ListPreference?,android,switch-statement,listpreference,Android,Switch Statement,Listpreference,我有一个prefs.xml文件 <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <CheckBoxPreference android:title="aaa" android:defaultValue="true" andr
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:title="aaa"
android:defaultValue="true"
android:key="checkbox"
android:summary=""/>
<CheckBoxPreference
android:title="bbb"
android:defaultValue="true"
android:key="checkbox1"
android:summary=""/>
<ListPreference
android:title="first page"
android:key="first_page"
android:summary="ccc"
android:defaultValue="3"
android:entries="@array/list"
android:entryValues="@array/lvalues"
></ListPreference>
</PreferenceScreen>
array.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="list">
<item >1</item>
<item >2</item>
<item >3</item>
<item >4</item>
</string-array>
<string-array name="lvalues">
<item >1</item>
<item >2</item>
<item >3</item>
<item >4</item>
</string-array>
</resources>
1.
2.
3.
4.
1.
2.
3.
4.
我想在主java类的“switch-case”中使用ListPreference中的entryvalues,以便根据用户的首选项显示第一页。
我该怎么做?
非常感谢你的帮助