Java Code Examples for android.support.v7.preference.ListPreference#setEntryValues()
The following examples show how to use
android.support.v7.preference.ListPreference#setEntryValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsActivity.java From video-quickstart-android with MIT License | 5 votes |
private void setupCodecListPreference(Class codecClass, String key, String defaultValue, ListPreference preference) { List<String> codecEntries = new ArrayList<>(); if(codecClass == AudioCodec.class){ Collections.addAll(codecEntries, AUDIO_CODEC_NAMES); }else{ Collections.addAll(codecEntries, VIDEO_CODEC_NAMES); } // Remove H264 if not supported if (!MediaCodecVideoDecoder.isH264HwSupported() || !MediaCodecVideoEncoder.isH264HwSupported()) { codecEntries.remove(H264Codec.NAME); } String[] codecStrings = codecEntries.toArray(new String[codecEntries.size()]); // Saved value final String value = sharedPreferences.getString(key, defaultValue); // Bind values preference.setEntries(codecStrings); preference.setEntryValues(codecStrings); preference.setValue(value); preference.setSummary(value); preference.setOnPreferenceChangeListener((preference1, newValue) -> { preference1.setSummary(newValue.toString()); return true; }); }
Example 2
Source File: Settings.java From isu with GNU General Public License v3.0 | 4 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { getPreferenceManager().setSharedPreferencesName(Constants.PREF_NAME); addPreferencesFromResource(R.xml.settings); mSettingsPref = (PreferenceCategory) findPreference("settings_pref"); mSettingsView = (Preference) findPreference("settings_view"); mSettingsForceEnglish = (SwitchPreference) findPreference("forceenglish"); mSettingsForceEnglish.setOnPreferenceChangeListener(this); mSettingsSU = (PreferenceCategory) findPreference("su_settings_pref"); mSettingsMonitor = (PreferenceCategory) findPreference("monitor_settings"); mSettingsNotifications = (PreferenceCategory) findPreference("notifications_settings_pref"); mSettingsSelinux = (PreferenceCategory) findPreference("selinux_settings_pref"); mSettingsDebug = (PreferenceCategory) findPreference("anddebug_settings_pref"); mSettingsProps = (PreferenceCategory) findPreference("props_settings_pref"); mApplySuDelay = (ListPreference) findPreference("apply_su_delay"); mApplyMonitorDelay = (ListPreference) findPreference("allow_delay"); CharSequence[] entriesSuDelay = new CharSequence[6]; CharSequence[] entryValuesSuDelay = new CharSequence[6]; for (int i = 0; i < 6; i++) { entriesSuDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i + 1) * 10))); entryValuesSuDelay[i] = String.valueOf((i + 1) * 10000); } mApplySuDelay.setEntries(entriesSuDelay); mApplySuDelay.setEntryValues(entryValuesSuDelay); CharSequence[] entriesMonitorDelay = new CharSequence[7]; CharSequence[] entryValuesMonitorDelay = new CharSequence[7]; for (int i = 0; i < 7; i++) { if (i == 0) { entriesMonitorDelay[i] = getString(R.string.disable); entryValuesMonitorDelay[i] = String.valueOf(i); } else { entriesMonitorDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i) * 5))); entryValuesMonitorDelay[i] = String.valueOf((i) * 5000); } } mApplyMonitorDelay.setEntries(entriesMonitorDelay); mApplyMonitorDelay.setEntryValues(entryValuesMonitorDelay); suVersion = Tools.SuVersion(getActivity()); isCMSU = Tools.SuVersionBool(suVersion); if (!isCMSU) { mSettingsSU.setEnabled(false); mSettingsMonitor.setEnabled(false); mSettingsNotifications.setEnabled(false); mSettingsSelinux.setEnabled(false); mSettingsDebug.setEnabled(false); if (!Tools.rootAccess(getActivity())) { mSettingsView.setSummary(getString(R.string.device_not_root)); mSettingsProps.setEnabled(false); } } else mSettingsPref.removePreference(mSettingsView); }