androidpreferenceactivityedittextpreference

PreferenceActivity - EditTextPreference - on value changed


I have an EditTextPreference (key "userfirstname"). I want to call method when it has been changed. I read documentation of PreferenceActivity and EditTextPreference, but I didn't find relevant solution.

Is there any way to do that ?


Solution

  • Preference userNamePref = findPreference("userfirstname");
    userNamePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
    
            @Override
            public boolean onPreferenceChange(Preference preference,
                    Object newValue) {
                //do something
                return true;
            }
    
    });