gpt4 book ai didi

android - 从对话框中保存首选项

转载 作者:行者123 更新时间:2023-11-30 04:04:27 26 4
gpt4 key购买 nike

在我的 Preferences 屏幕中打开自定义 Dialog 后,如何在 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;
}
});
}
}

最佳答案

SharedPreferences preferences = getPreferenceManager().getSharedPreferences(); 
preferences.edit().putString("clockfontcolor", "-9856").commit();

关于android - 从对话框中保存首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971418/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com