我PreferemceActivity從XML充氣:PreferenceActivity刷新問題
<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_Appendix" />
</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>
一首(複選框)其他複選框的變換狀態:
if("ShowContactPhotosCheckBoxPref_Appendix".equals(key)){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
boolean isChecked = prefs.getBoolean("ShowContactPhotosCheckBoxPref_Appendix", false);
Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit();
editor.putBoolean("ShowContactPhotosCheckBoxPref", isChecked);
editor.commit();
}
但是,當我去ShowContactPhotosCheckBoxPref篩選仍保持以前的偏好值... 因此,如果我點擊ShowContactPhotosCheckBoxPref_Appendix - 他的狀態現在是未選中狀態,然後用ShowContactPhotosCheckBoxPref進入屏幕 - 他的狀態仍然檢查,但SharedPreferences中的值爲false ...
如何告訴PreferenceActivity刷新其價值?
沒有,我改變數值。 ShowContactPhotosCheckBoxPref的值必須與ShowContactPhotosCheckBoxPref_Appendix的值相同 – vsvydenko 2011-04-13 09:12:21
對不起,我的錯誤。我沒有正確閱讀你的帖子。 – rajath 2011-04-13 09:14:46
因此,如果我點擊ShowContactPhotosCheckBoxPref_Appendix - 他的狀態現在是未選中狀態,然後使用ShowContactPhotosCheckBoxPref進行屏幕顯示 - 他的狀態仍然被選中,但SharedPreferences中的值爲false ... – vsvydenko 2011-04-13 09:17:05