How can I use ListPreference with Switch in Android?
I have 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"
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>
xml array
<?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>
and I want to use entryvalues ββfrom ListPreference to "switch-case" in main java class to use it to display the first page according to users preference. How can i do this? Many thanks for the help!
+3
source to share
No one has answered this question yet
Check out similar questions: