Hi everyone,
In my app I'd like to show a warning when using a certain preference in my application. I've tried using the PreferenceActivity.onPreferenceTreeClick and the onPreferenceClickListener, but neither seems to work. I've got the latter example below. Could anyone shed some light on this please?
@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();
}