PreferenceScreen android:summary update ! PreferenceScreen android:summary update ! android android

PreferenceScreen android:summary update !


Use

Parent.setSummary("string depending on the selection");((BaseAdapter)getPreferenceScreen().getRootAdapter()).notifyDataSetChanged();

works like a charm and can be used regardless the place you change the summary.


This is the correct way

Preference pref = findPreference(getString(R.string.key_of_pref));PreferenceScreen parent = (PreferenceScreen) sf.findPreference(getString(R.string.key_of_preference_screen));pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {   @Override   public boolean onPreferenceChange(Preference preference, Object newValue) {       boolean newValueBool = (Boolean) newValue;       parent.setSummary(newValueBool ? "Summary is true" : "Summary is false");                                                         ((BaseAdapter) getPreferenceScreen().getRootAdapter()).notifyDataSetChanged();       // true to update the state of the Preference with the new value       // in case you want to disallow the change return false       return true;  }});


I discovered that it seems to work by following up setSummary() with getListView().invalidate()