xmlからPreferemceActivityを膨らませました:
<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>
設定(チェックボックス)の1つは、他のチェックボックスの状態を変更します。
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にその値を更新するように指示するにはどうすればよいですか?