5 android preference checkboxpreference preferencescreen android-settings
我有一个首选项xml文件,在某些时候它看起来像这样:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Hello there">
<!-- Profile ** -->
<PreferenceScreen
android:key="profile"
android:summary="Let app access my profile info such as name, picture and other account information."
android:title="User Profile">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_profile"
android:summary="Let app access my profile such as name, picture and other account information."
android:title="My Profile" />
Run Code Online (Sandbox Code Playgroud)
如您所见,我有2个preferenceScreen。我想获取CheckBoxPreference的preferenceScreen(所以带有key的profile屏幕:profile)。当我使用时:
PreferenceScreen prefScreen = getPreferenceScreen();
Run Code Online (Sandbox Code Playgroud)
我得到一个标题为:你好。我如何获得此checkBoxPreference的直接父(第一父)屏幕?我想要得到它,以便我可以禁用或启用其视图。
有什么想法吗?谢谢!!