【发布时间】:2013-01-16 00:01:38
【问题描述】:
我正在尝试使用 Android PreferenceScreen 作为一种方便的方式来布局我的用户设置,但我不想将首选项保存到设备共享首选项中。这可能吗,还是我应该使用不同的机制,例如ListView?
使用PreferenceScreen 类型似乎真的很方便,因为我需要不同的小部件(即开关、编辑文本)。但是我已经遇到了持久性问题,即。我输入的任何内容即使在我不希望的会话中也会保留。
settings.xml:
<?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" >
<Preference
android:key="settings_type"
android:title="@string/label_type" />
<EditTextPreference
android:key="settings_edit_name"
android:title="@string/label_name"
android:dialogTitle="Enter a name"
android:singleLine="true" />
<SwitchPreference
android:key="settings_edit_state"
android:title="@string/label_state"
android:summary="Enable or disable the state" />
</PreferenceScreen>
【问题讨论】:
标签: android android-layout android-widget