Search code examples
androidlistmethodspreference

Android execute method when ListPreference is selected


how can I execute a method as soon as a user selects an option in a ListPreference?


Solution

  • You can go that way:

    ListPreference pref = (ListPreference) findPreference("pref_name");
    pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
       yourAction();
    }