Tuesday, May 3, 2011

Display ListPreference value in the preferences screen

One missing feature in the preferences activity in Android applications is to display the selected value of a ListPreference. By default, to view the selected value of a ListPreference you must click the preference and see what's selected in the combo box.

Here's an example how to create a preferences activity which displays the selected value of any number of ListPreferences in the activity.


  • This code will update the values if the user selects a new value

  • If you're defining preferences keys in the strings.xml file, make the mListPreferencesKeys list an integer list, and get the string at run time using 'getString'

No comments: