ListPreference findIndexOfValue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListPreference findIndexOfValue method.

This code example shows how to use the following methods:findIndexOfValue, getEntries
 
            if (preference instanceof ListPreference) { 
                // For list preferences, look up the correct display value in 
                // the preference's 'entries' list. 
                ListPreference listPreference = (ListPreference) preference; 
                int index = listPreference.findIndexOfValue(stringValue); 
 
                // Set the summary to reflect the new value. 
                preference.setSummary( 
                        index >= 0 
                                ? listPreference.getEntries()[index] 
                                : null); 
 
            } else if (preference instanceof RingtonePreference) { 
                // For ringtone preferences, look up the correct display value 
                // using RingtoneManager. 
                if (TextUtils.isEmpty(stringValue)) { 
                    // Empty values correspond to 'silent' (no ringtone). 
                    // preference.setSummary(R.string.pref_ringtone_silent); 
 
7
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries, setSummary
        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));
    } 
 
    @Override 
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (preference == mHomeLongPressAction) {
            handleActionListChange(mHomeLongPressAction, newValue,
                    Settings.System.KEY_HOME_LONG_PRESS_ACTION); 
            return true; 
        } else if (preference == mHomeDoubleTapAction) {
            handleActionListChange(mHomeDoubleTapAction, newValue,
                    Settings.System.KEY_HOME_DOUBLE_TAP_ACTION); 
8
CodeRank
This code example shows how to use the following methods:findIndexOfValue
    @Override 
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        String key = preference.getKey();
 
        if (PREFERENCE_KEY_AUTO_ADVANCE.equals(key)) {
            mPreferences.setAutoAdvanceDirection(mAutoAdvance.findIndexOfValue((String) newValue));
            return true; 
        } else if (PREFERENCE_KEY_TEXT_ZOOM.equals(key)) {
            mPreferences.setTextZoom(mTextZoom.findIndexOfValue((String) newValue));
            reloadDynamicSummaries(); 
            return true; 
        } 
        return false; 
    } 
 
    @Override 
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (getActivity() == null) {
            // Guard against monkeys. 
            return false; 
6
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries
			if ( preference instanceof ListPreference ) 
			{ 
				// For list preferences, look up the correct display value in 
				// the preference's 'entries' list. 
				ListPreference listPreference = (ListPreference) preference; 
				int index = listPreference.findIndexOfValue( stringValue ); 
 
				// Set the summary to reflect the new value. 
				preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null ); 
 
			} 
 
			else 
			{ 
				// For all other preferences, set the summary to the value's 
				// simple string representation. 
				preference.setSummary( stringValue ); 
			} 
			return true; 
		} 
7
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries, setSummary
    } 
 
    public boolean onPreferenceChange(Preference pref, Object newValue) {
        if (KEY_ALARM_SNOOZE.equals(pref.getKey())) {
            final ListPreference listPref = (ListPreference) pref;
            final int idx = listPref.findIndexOfValue((String) newValue);
            listPref.setSummary(listPref.getEntries()[idx]);
        } else if (KEY_AUTO_SILENCE.equals(pref.getKey())) {
            final ListPreference listPref = (ListPreference) pref;
            String delay = (String) newValue;
            updateAutoSnoozeSummary(listPref, delay);
        } 
        return true; 
    } 
 
    private void updateAutoSnoozeSummary(ListPreference listPref,
            String delay) {
        int i = Integer.parseInt(delay);
        if (i == -1) {
            listPref.setSummary(R.string.auto_silence_never);
7
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries, setSummary
This code example shows how to use the following methods:findIndexOfValue, getEntries, setSummary
This code example shows how to use the following methods:findIndexOfValue, getEntries
 
			if (preference instanceof ListPreference) { 
				// For list preferences, look up the correct display value in 
				// the preference's 'entries' list. 
				ListPreference listPreference = (ListPreference) preference; 
				int index = listPreference.findIndexOfValue(stringValue); 
 
				// Set the summary to reflect the new value. 
				preference 
						.setSummary(index >= 0 ? listPreference.getEntries()[index] 
								: null); 
 
			}  else { 
				// For all other preferences, set the summary to the value's 
				// simple string representation. 
				preference.setSummary(stringValue); 
			} 
			return true; 
		} 
	}; 
7
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries
 
            if (preference instanceof ListPreference) { 
                // For list preferences, look up the correct display value in 
                // the preference's 'entries' list. 
                ListPreference listPreference = (ListPreference) preference; 
                int index = listPreference.findIndexOfValue(stringValue); 
 
                // Set the summary to reflect the new value. 
                preference.setSummary( 
                        index >= 0 
                                ? (listPreference.getEntries()[index]) 
                                .toString().replaceAll("%", "%%") 
                                : null); 
 
            } else if (preference instanceof RingtonePreference) { 
                // For ringtone preferences, look up the correct display value 
                // using RingtoneManager. 
                if (TextUtils.isEmpty(stringValue)) { 
                    // Empty values correspond to 'silent' (no ringtone). 
                    //preference.setSummary(R.string.pref_ringtone_silent); 
7
CodeRank
This code example shows how to use the following methods:findIndexOfValue, getEntries, setSummary

Related ListPreference findIndexOfValue Questions & Answers:

findIndexOfValue Method Overview
Returns the index of the given value (in the entry values array).
See Code Examples for other Android ListPreference Methods: