I have a ListPreference with values "A", "B", and "C".
I have set the summary to "%1$s".
According to the documentation, the preference is supposed to use the
supplied summary string (%1$s) with a formatter (java.util.Formatter)
so that the real summary string value reflects the currrent preference
value.
Sure enough, if I call listPreference.getSummary(), it returns "A",
"B" or "C" correctly, depending on what the current value of the
preference is.
However, when the user edits the preference (by clicking on its row in
a PreferenceFragment) and then selects a value on the alert dialog,
the text view for the summary in the list doesn't update.
getSummary() doesn't get called.
You can work around it by extending ListPreference and overriding
setValue(Object value) to add a notifyChanged():
@Override
public void setValue(String value) {
super.setValue(value);
notifyChanged();
}
I believe that's a bug and it should do that by default (there might
be a more efficient way to fix it, but at least the summary text view
should update).
The system preferences (e.g. Sound/Vibrate) look like good candidates
for using this feature, but they are not. They update the summary
manually. Is it because of this bug?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en