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 相反?


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01