<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
...
</PreferenceScreen>
<PreferenceCategory
android:title="In-Line preference"
android:key="pc_1">
<CheckBoxPreference
android:key="pref_cb"
android:title="Checkbox preference"
android:summary="this is a checkbox"
android:defaultValue="true" />
</PreferenceCategory>
EditTextPreference
ListPreference
<PreferenceCategory
android:title="Dialog-based preference"
android:key="pc_2">
<EditTextPreference
android:key="pref_et"
android:title="Edit Text preference"
android:summary="an example that uses an edit text diglog"
/>
<ListPreference
android:key="pref_list"
android:title="List preference"
android:summary="an example that uses a list dialog"
android:entries="@array/choose"
android:entryValues="@array/chooseValue"
android:dialogTitle="Choose one">
</ListPreference>
</PreferenceCategory>
ListPreference的键值对设置:
<string-array name="choose">
<item>Alpha Option 01 </item>
<item>Beta Option 02</item>
<item>Charlie Option 03</item>
</string-array>
<string-array name="chooseValue">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
PreferenceScreen: 跳转到另一个PreferenceScreen
<PreferenceScreen
android:key="pref_screen"
android:persistent="false"
android:summary="shows another screen of preferences"
android:title="Screen preference">
<CheckBoxPreference
android:key="pref_cb2"
android:summary="@string/pref_cb2_summary" />
</PreferenceScreen>
<Preference
android:summary="@string/pref_intent_summary"
android:title="Intent preference">
<intent
android:action="android.intent.action.VIEW"
android:data="https://github.com/he476" />
</Preference>
CheckBox: 父选项 CheckBox: 子选项,当父选项勾选时呈现
<PreferenceCategory
android:key="pc_4"
android:title="Preference attribute">
<CheckBoxPreference
android:key="pref_cb3"
android:title="Parent checkbox preference"
android:summary="this is visually a parent"
android:defaultValue="false"
/>
<CheckBoxPreference
android:key="pref_cb4"
android:title="Child checkbox preference"
android:summary="this is visually a child"
android:dependency="pref_cb3"
/>
</PreferenceCategory>




