【发布时间】:2012-07-28 13:55:10
【问题描述】:
我目前正在做一个 Android 安全应用程序,并且在满足某些条件后,我正在尝试取消选中 CheckboxPreference。所以我试图通过这样做来取消选中复选框,默认情况下CheckBoxPreference实际上是false所以它没有被选中。
偏好:
<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>
SharedPreferences 内Activity:
SharedPreferences sp = getSharedPreferences("isPhysicalTheftEnabled", MODE_WORLD_READABLE);
SharedPreferences.Editor ed = sp.edit();
ed.putBoolean("isPhysicalTheftEnabled", false);
ed.commit();
即使我这样做了,CheckBoxPreference 也不会取消勾选。知道可能是什么问题吗?
【问题讨论】:
-
考虑重新加载您的preferenceActivity:stackoverflow.com/questions/7466189/…
标签: android checkbox sharedpreferences preference