How can I modify the summary of a ListPreference to the new \"Entry\" string selected by the user (not the entry value)
I suppouse its with setOnPreferenceChangeList
i solved this problem with another and simple solution (https://gist.github.com/brunomateus/5617025):
public class ListPreferenceWithSummary extends ListPreference{
public ListPreferenceWithSummary(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ListPreferenceWithSummary(Context context) {
super(context);
}
@Override
public void setValue(String value) {
super.setValue(value);
setSummary(value);
}
@Override
public void setSummary(CharSequence summary) {
super.setSummary(getEntry());
}
}
This worked very fine on my GirgerBeard device. Even when is the first time running your app. Don't forget to provide default value on your xml prefence:
android:defaultValue="default value"
and set default values on your PreferenceActivity
or PrefenceFragment
:
PreferenceManager.setDefaultValues(this, R.xml.you pref file, false);