Android ListPreference - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getEntry, setSummary, setValue
    } 
 
    private void updateState() { 
 
        mVibrateMode.setValue(mProfileGroup.getVibrateMode().name());
        mSoundMode.setValue(mProfileGroup.getSoundMode().name());
        mRingerMode.setValue(mProfileGroup.getRingerMode().name());
        mLightsMode.setValue(mProfileGroup.getLightsMode().name());
 
        mVibrateMode.setSummary(mVibrateMode.getEntry());
        mSoundMode.setSummary(mSoundMode.getEntry());
        mRingerMode.setSummary(mRingerMode.getEntry());
        mLightsMode.setSummary(mLightsMode.getEntry());
 
        if (mProfileGroup.getSoundOverride() != null) {
            mSoundTone.setRingtone(mProfileGroup.getSoundOverride());
        } 
 
        if (mProfileGroup.getRingerOverride() != null) {
            mRingTone.setRingtone(mProfileGroup.getRingerOverride());
8
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSummary, setValue, getKey
            updateEntry(pref);
        } 
    } 
 
    private void updateEntry(ListPreference pref) {
        String value = Settings.System.getString(getContentResolver(), pref.getKey());
        if (value == null) {
            value = "";
        } 
 
        CharSequence entry = findEntryForValue(pref, value);
        if (entry != null) {
            pref.setValue(value);
            pref.setSummary(entry);
            return; 
        } 
    } 
 
    private CharSequence findEntryForValue(ListPreference pref, CharSequence value) {
        CharSequence[] entries = pref.getEntryValues();
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSummary, setValue
        String temp;
 
        super.onResume(); 
 
        temp = readOneLine(FREQ_MAX_FILE);
        mMaxFrequencyPref.setValue(temp);
        mMaxFrequencyPref.setSummary(String.format(mMaxFrequencyFormat, toMHz(temp)));
 
        temp = readOneLine(FREQ_MIN_FILE);
        mMinFrequencyPref.setValue(temp);
        mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp)));
 
        temp = readOneLine(GOVERNOR);
        mGovernorPref.setSummary(String.format(mGovernorFormat, temp));
    } 
 
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        String fname = "";
 
        if (newValue != null) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getEntry, setSummary
		if (p != null && p instanceof ListPreference) updateSummary((ListPreference)p);
	} 
 
	void updateSummary(ListPreference lp)
	{ 
		lp.setSummary(lp.getEntry());
		getListView().postInvalidate();
	} 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: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
Experience pair programming with AI  Get Codota for Java

Related Android ListPreference Questions & Answers:

See Code Examples for Android ListPreference Methods: