Vishwa Madushan Vishwa Madushan - 7 months ago 28
Java Question

Update Textview right after user change settings value

In my app I let the user choose a name to display. It should display as:


I can successfully update settings. I used PreferenceActivity.
I can change the value too. But to change the text in the selected textview, I have to restart the app.

How can I update my textview right after users update the value in settings?

Preference.OnPreferenceChangeListener changeListener = new Preference.OnPreferenceChangeListener() {
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        // Code goes here            
        return true;

EditTextPreference pref = (EditTextPreference)findPreference(getString(R.string.pref1));

EditTextPreference pref2 = (EditTextPreference)findPreference(getString(R.string.pref2));