Code example for ListPreference

Methods: setOnPreferenceChangeListener, getEntry, setEntries, setEntryValues, setSummary, setValue

0
     * @param entryValues The array to find the value to save for a preference when an 
     *                    entry from entries is selected. 
     */ 
    protected void initListPreference(final ListPreference prefView, final String value,
                                      final CharSequence[] entries, final CharSequence[] entryValues) {
        prefView.setEntries(entries);
        prefView.setEntryValues(entryValues);
        prefView.setValue(value);
        prefView.setSummary(prefView.getEntry());
        prefView.setOnPreferenceChangeListener(new PreferenceChangeListener(prefView));
    } 
 
    /** 
     * This class handles value changes of the {@link ListPreference} objects. 
     */ 
    private static class PreferenceChangeListener implements Preference.OnPreferenceChangeListener {
        private ListPreference mPrefView;
 
        private PreferenceChangeListener(final ListPreference prefView) {
            this.mPrefView = prefView;
        }