如何与偏好属性 android:dependency 相反? [英] How to do opposite of of preference attribute android:dependency?

查看:21
本文介绍了如何与偏好属性 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:dependencycode> 将按照我想要的相反方式切换它.

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 相反?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆