我的settings.xml中有两个CheckBoxes。每个复选框都有相同的键"ShowContactPhotosCheckBoxPref":
<PreferenceScreen
android:title="Appearence"
android:key="AppearencePref" >
......
<PreferenceCategory
android:title="Show Contact Photos">
<CheckBoxPreference
android:title="Show Contact Photos"
android:summary="@string/show_contact_photos_preference"
android:defaultValue="true"
android:key="ShowContactPhotosCheckBoxPref" />
</PreferenceCategory>
........
</PreferenceScreen>
.......
<PreferenceScreen
android:title="Contact Options"
android:key="ContactOtionsPref">
<PreferenceCategory
android:title="Show Contact Photos">
<CheckBoxPreference
android:title="Show Contact Photos"
android:defaultValue="true"
android:key="ShowContactPhotosCheckBoxPref" />
</PreferenceCategory>
......
</PreferenceScreen>启动应用程序状态后,chekbox№1 = chekbox№2 = true。当我单击复选框状态1(状态未选中),然后转到复选框№2 -№选中时,但在我的SharedPreferences文件中,ShowContactPhotosCheckBoxPref的状态为false。是否可以同步这些chekboxes?
发布于 2011-06-14 22:09:04
在不同的首选项屏幕中为两个键命名相同并不意味着它们是相同的键。实际上,使用唯一的键名是一种很好的做法。选中/取消选中时,使用单个复选框首选项或以编程方式更新两个首选项中每个首选项的设置。
https://stackoverflow.com/questions/5626891
复制相似问题