gpt4 book ai didi

Android PreferenceScreen - 我可以在不将首选项保存到 SharedPreferences 的情况下使用它吗?

转载 作者:可可西里 更新时间:2023-11-01 19:03:29 25 4
gpt4 key购买 nike

我正在尝试使用 Android PreferenceScreen 作为布局我的用户设置的便捷方式,但我不想将首选项保存到设备共享首选项。这可能吗,还是我应该使用不同的机制,例如 ListView

使用 PreferenceScreen 类型似乎非常方便,因为我需要不同的小部件(即开关、编辑文本)。但是我已经遇到了持久性问题,即。当我不希望它存在时,我输入的任何内容甚至会在 session 中保留。

设置.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:persistent="false"

关于Android PreferenceScreen - 我可以在不将首选项保存到 SharedPreferences 的情况下使用它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14633351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com