How to do opposite of of preference attribute android:dependency?(如何与偏好属性 android:dependency 相反?)
问题描述
是否有与 android:dependency
完全相反的 XML 属性?
Is there XML attribute that does the exact opposite of android:dependency
?
我希望在未选中另一个时启用依赖首选项并在选中时禁用它.
What I would like the dependent preference to be enabled when the other is NOT checked and disabled when it IS checked.
edit:也许问题不在于 android:dependency
也许我可以添加一个 xml 属性以禁用该首选项的默认值,然后 android:dependency
code> 将按照我想要的相反方式切换它.
edit: maybe the issue isn't with android:dependency
maybe there is an xml attribute that I can add to make the default for that preference disabled and then android:dependency
will toggle it the opposite way like i want.
再次我尝试在首选项中设置 android:enabled="false"
并像我想要的那样禁用它,但即使它依赖于其他首选项它也没有像我希望的那样启用它
edit again:
I tried setting android:enabled="false"
in the preference and it disables it like i want but even with it being dependent on the other preference it didn't enable it like i had hoped
推荐答案
实际上是我自己找到的,想把它贴在这里来帮助任何可能遇到同样问题的人:
Actually found it on my own and figured I'd just post it here to help anyone that might have this same issue:
android:disableDependentsState="true"
把它放在控制偏好中.
这篇关于如何与偏好属性 android:dependency 相反?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何与偏好属性 android:dependency 相反?


基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01