Code example for ListPreference

Methods: findIndexOfValuegetEntriessetSummary

0
        return list;
    } 
 
    private void handleActionListChange(ListPreference pref, Object newValue, String setting) {
        String value = (String) newValue;
        int index = pref.findIndexOfValue(value);
 
        pref.setSummary(pref.getEntries()[index]);
        Settings.System.putInt(getContentResolver(), setting, Integer.valueOf(value));
    } 
 
    private void handleCheckboxClick(CheckBoxPreference pref, String setting) {
        Settings.System.putInt(getContentResolver(), setting, pref.isChecked() ? 1 : 0);
    } 
 
    @Override 
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (preference == mHomeLongPressAction) {
            handleActionListChange(mHomeLongPressAction, newValue,
                    Settings.System.KEY_HOME_LONG_PRESS_ACTION); 
Contextual code suggestions in your IDE  Get Codota for Java