在我的Dialog
屏幕中打开自定义Preferences
后,如何在Dialog
消失后保存到该特定偏好设置?
public class Preferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.task_preferences);
Preference dialogPreference = (Preference) findPreference(getString(R.string.clock_font_color));
dialogPreference.setOnPreferenceClickListener( new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
dialog(); ////How save here//????
return true;
}
});
}
}
答案 0 :(得分:1)
SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
preferences.edit().putString("clockfontcolor", "-9856").commit();