5

我有一个 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

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

我想在主java类的“switch - case”中使用ListPreference中的entryvalues,以便根据用户偏好使用它来显示第一页。我怎样才能做到这一点?非常感谢您的帮助!

4

0 回答 0