How do I display the current value of an Android Preference in the Preference summary?

Posted by nyenyec on Stack Overflow See other posts from Stack Overflow or by nyenyec
Published on 2009-02-10T08:02:50Z Indexed on 2010/04/23 9:33 UTC
Read the original article Hit count: 201

Filed under:
|
|

This must come up very often.

When the user is editing preferences in an Android app, I'd like them to be able to see the currently set value of the preference in the Preference summary.

Example: if I have a Preference setting for "Discard old messages" that specifies the number of days after which messages need to be cleaned up. In the PreferenceActivity I'd like the user to see:

"Discard old messages" <- title

"Clean up messages after x days" <- summary where x is the current Preference value

Extra credit: make this reusable, so I can easily apply it to all my preferences regardless of their type (so that it work with EditTextPreference, ListPreference etc. with minimal amount of coding).

© Stack Overflow or respective owner

Related posts about android

Related posts about gui