views:

109

answers:

2

I have a simple preference (not EditText preference or ListPreference). I have a method that deletes all files in a directory. I want to do this when user clicks on a preference, but i don't know how to react to a click on a preference.

+1  A: 

if your preference is stored in an object(togglePref) you can do this

togglePref.setOnPreferenceClickListener(this);

then the event is:

@Override
public boolean onPreferenceClick(Preference preference) {

}
Pentium10
+5  A: 
getPreferenceManager().findPreference("pref_key").setOnPreferenceClickListener(new OnPreferenceClickListener()
{
    @Override
    public boolean onPreferenceClick(Preference preference)
    {
        // Do stuff here
    }
});
CaseyB
Tnx for you fast answer.
DixieFlatline