【发布时间】:2012-07-30 11:51:43
【问题描述】:
我目前正在做一个 android 安全应用程序,我试图在满足某些条件后取消选中 CheckboxPreferences,所以我试图通过这样做来取消选中复选框
活动:
SharedPreferences sp = getSharedPreferences("isPhysicalTheftEnabled", MODE_WORLD_READABLE);
SharedPreferences.Editor ed = sp.edit();
ed.putBoolean("isPhysicalTheftEnabled", false);
ed.commit();
preferences.xml
<CheckBoxPreference
android:id="@+id/isPhysicalTheftEnabled"
android:key="isPhysicalTheftEnabled"
android:title="Enable Physical Theft Protection"
android:summary="Select to enable the Physical Theft Protection"
android:defaultValue="false"/>
<Preference android:key="physicaltheft" android:title="Set Physical Theft Protection Password" android:dependency="isPhysicalTheftEnabled"></Preference>
但即使在我执行 ed.commit(); 之后 CheckBoxPreference 也不会被取消选中;知道为什么会这样吗?
【问题讨论】:
标签: android checkbox preference