0

use this code, in the Preferences activity, to know when the reset preference has been clicked:

    Preference reset = findPreference(res.getString(R.string.reset_text));
    reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference p) {
            // TODO stuff              
            return true;
        }
    });

I think the argument Preference p is going to be always the reset Preference, since this is a dedicated listener to it being clicked. Am I right? Or do I have to check the right Preference was clicked?

ilomambo
  • 8,290
  • 12
  • 57
  • 106

1 Answers1

1

You are right. In case of dedicated listeners, you need not check for the parameter. But you may note that the listener instances can be shared across preferences, if required, in which case the parameter will uniquely identify the preference being clicked.

Rajesh
  • 15,724
  • 7
  • 46
  • 95