gpt4 book ai didi

android - 覆盖点击android preferenceactivity

转载 作者:太空宇宙 更新时间:2023-11-03 13:38:21 34 4
gpt4 key购买 nike

在我的应用程序中,我想在我的应用程序中使用特定首选项时显示警告。我试过使用 PreferenceActivity.onPreferenceTreeClick 和 onPreferenceClickListener,但似乎都不起作用。我在下面得到了后一个例子。有人可以对此有所了解吗?

@Override
protected void onCreate(Bundle saved) {

super.onCreate(saved);
addPreferencesFromResource(R.xml.prefs);
Preference gridview = findPreference("fcngrid");
gridview.setOnPreferenceClickListener(overrider);

}

public OnPreferenceClickListener overrider = new OnPreferenceClickListener() {

public boolean onPreferenceClick(Preference pref) {

if (pref.getTitle() == "Default as grid")
showDialog(0);

return false;
}

};

protected Dialog onCreateDialog(int id) {

AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle("Warning")
.setMessage("Unfortunately, this feature is currently unstable, and will be" +
" fixed soon.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {

dialog.cancel();

}

});

return b.create();

}

最佳答案

别担心,使用 pref.getTitle().equals("Default as grid") 效果很好。

关于android - 覆盖点击android preferenceactivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3692528/

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