【发布时间】:2021-09-26 15:49:11
【问题描述】:
我在 android studio 中的 root_preferences.xml 中存在依赖问题。我想为我的应用添加简单的设置,但其中一些设置仅适用于女性或男性。
所以我在这里有简单的 CheckBoxPreference
<CheckBoxPreference
app:key="pregnant"
app:title="Pregnant"
app:defaultValue="false"/>
只有在您提交性别时选中第一个活动上的单选按钮时才应启用它
<RadioButton
android:id="@+id/Female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:text="Female"
android:buttonTint="@color/black"/>
那么我怎样才能为男性禁用此 CheckBoxPreference 并为女性启用它?
【问题讨论】:
-
禁用
RadioButton非常简单,但您的问题缺少大量信息。 第一个活动是什么?是登录页面吗?信息保存在哪里?性别是否存储在root_preferences.xml中? -
如果用户是男性,我想禁用复选框首选项,我尝试在 sharedpreferences 中保存布尔值,但我不知道如何从代码中禁用复选框首选项,而不是从 xml 中
标签: java android dependencies radio-button android-preferences