Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion ListPreference summary
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
program  
View profile  
 More options Feb 8 2012, 9:10 am
From: program <programin...@gmail.com>
Date: Wed, 8 Feb 2012 06:10:51 -0800 (PST)
Local: Wed, Feb 8 2012 9:10 am
Subject: ListPreference summary
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.