【发布时间】:2019-02-06 00:16:52
【问题描述】:
找不到偏好“屏幕”的依赖项“开关”
当我使用 ListPreference 时,android:dependency="switch" 一切正常,当我关闭 android:dependency="switch" 时,我可以打开 PreferenceScreen。
但要解锁 SwitchPreference 并打开 PreferenceScreen - 会出错。
java.lang.IllegalStateException:找不到首选项“屏幕”的依赖项“开关”(标题:“屏幕”
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:title="Switch"
android:key="switch"
android:summaryOn="Description of switch 2 on"
android:summaryOff="Description of switch 2 off"/>
<PreferenceScreen
android:dependency="switch"
android:key="screen"
android:summaryOn="Description of screen on"
android:summaryOff="Description of screen off"
android:title="Screen">
<CheckBoxPreference
android:summaryOn="Description of checkbox on"
android:summaryOff="Description of checkbox off"
android:title="CheckBox"
android:key="checkbox"/>
</PreferenceScreen>
</PreferenceScreen>
【问题讨论】:
标签: android