CharSequence[] entries = { "One", "Two", "Three" }; CharSequence[] entryValues = { "1", "2", "3" }; ListPreference lp = (ListPreference)findPreference("list_key_as_defined_in_xml"); lp.setEntries(entries); lp.setEntryValues(entryValues);
ListPreference listPreferenceCategory = (ListPreference) findPreference("default_category"); if (listPreferenceCategory != null) { ArrayList<Category> categoryList = getCategories(); CharSequence entries[] = new String[categoryList.size()]; CharSequence entryValues[] = new String[categoryList.size()]; int i = 0; for (Category category : categoryList) { entries[i] = category.getCategoryName(); entryValues[i] = Integer.toString(i); i++; } listPreferenceCategory.setEntries(entries); listPreferenceCategory.setEntryValues(entryValues); }
CharSequence[] entries = { "One", "Two", "Three" }; CharSequence[] entryValues = { "1", "2", "3" }; ListPreference lp = new ListPreference(this); lp.setEntries(entries); lp.setEntryValues(entryValues);
private void initializeLanguageDialog(PreferenceScreen screen) { ListPreference languageSelection = (ListPreference) screen.findPreference(LANGUAGE); if (languageSelection != null) { Map<String, String> items = new TreeMap<>(); for (String localeCode : LanguageUtil.APP_LANGUAGES) { Locale loc = LanguageUtil.getLocale(localeCode); items.put(loc.getDisplayName(), loc.toString()); } CharSequence[] languageDialogLabels = new CharSequence[items.size() + 1]; CharSequence[] languageDialogValues = new CharSequence[items.size() + 1]; languageDialogLabels[0] = getResources().getString(R.string.language_system); languageDialogValues[0] = ""; int i = 1; for (Map.Entry<String, String> e : items.entrySet()) { languageDialogLabels[i] = e.getKey(); languageDialogValues[i] = e.getValue(); i++; } languageSelection.setEntries(languageDialogLabels); languageSelection.setEntryValues(languageDialogValues); } }
prefVolumes.setEntryValues(uuids);
/** Initializes the list of custom fonts shown in the preferences. */ private void initializeCustomFontsDialog(PreferenceScreen screen) { ListPreference defaultFontPreference = (ListPreference) screen.findPreference("defaultFont"); if (defaultFontPreference != null) { defaultFontPreference.setEntries(getCustomFonts("System default")); defaultFontPreference.setEntryValues(getCustomFonts("")); } ListPreference browserEditorCustomFontsPreference = (ListPreference) screen.findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
@SuppressWarnings("deprecation") // Tracked as #5019 on github protected void buildLists() { ListPreference newOrderPref = (ListPreference) findPreference("order"); newOrderPref.setEntries(R.array.cram_deck_conf_order_labels); newOrderPref.setEntryValues(R.array.cram_deck_conf_order_values); newOrderPref.setValue(mPref.getString("order", "0")); }
@SuppressWarnings("deprecation") // Tracked as #5019 on github protected void buildLists() { ListPreference deckConfPref = (ListPreference) findPreference("deckConf"); ArrayList<JSONObject> confs = mCol.getDecks().allConf(); Collections.sort(confs, new JSONNameComparator()); String[] confValues = new String[confs.size()]; String[] confLabels = new String[confs.size()]; try { for (int i = 0; i < confs.size(); i++) { JSONObject o = confs.get(i); confValues[i] = o.getString("id"); confLabels[i] = o.getString("name"); } } catch (JSONException e) { throw new RuntimeException(e); } deckConfPref.setEntries(confLabels); deckConfPref.setEntryValues(confValues); deckConfPref.setValue(mPref.getString("deckConf", "0")); ListPreference newOrderPref = (ListPreference) findPreference("newOrder"); newOrderPref.setEntries(R.array.new_order_labels); newOrderPref.setEntryValues(R.array.new_order_values); newOrderPref.setValue(mPref.getString("newOrder", "0")); ListPreference leechActPref = (ListPreference) findPreference("lapLeechAct"); leechActPref.setEntries(R.array.leech_action_labels); leechActPref.setEntryValues(R.array.leech_action_values); leechActPref.setValue(mPref.getString("lapLeechAct", "0")); }
listPreferenceTargetLanguage.setEntryValues(R.array.translationtargetiso6391_microsoft); listPreferenceTargetLanguage.setEntryValues(R.array.translationtargetiso6391_google);
@Test public void shouldHaveEntryValues() { CharSequence[] entryValues = { "this", "is", "only", "a", "test" }; assertThat(listPreference.getEntryValues()).isNull(); listPreference.setEntryValues(entryValues); assertThat(listPreference.getEntryValues()).isSameAs(entryValues); }
@Test public void shouldSetEntryValuesByResourceId() { assertThat(listPreference.getEntryValues()).isNull(); listPreference.setEntryValues(R.array.greetings); assertThat(listPreference.getEntryValues()).isNotNull(); }
lp.setEntries(entries); lp.setDefaultValue("1"); lp.setEntryValues(entryValues);
/** * Initialize a given {@link ListPreference} instance. * * @param prefView * The {@link ListPreference} instance to initialize. * @param value * Initial value for the {@link ListPreference} object. * @param entries * Sets the human-readable entries to be shown in the list. * @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)); }
item = new ListPreference(this); ((ListPreference)item).setEntries(opt.getEnum()); ((ListPreference)item).setEntryValues(opt.getEnum()); ((ListPreference)item).setDialogTitle(opt.getName()); ((ListPreference)item).setValue(opt.getValue());
private void populateLogMessage(Preference logDmesg) { if (logDmesg == null) { return; } ArrayList<String> ar = new ArrayList<String>(); ArrayList<String> val = new ArrayList<String>(); ar.add("System"); val.add("OS"); ListPreference listPreference = (ListPreference) logDmesg; if (RootTools.isBusyboxAvailable()) { ar.add("Busybox"); val.add("BX"); } if (listPreference != null) { listPreference.setEntries(ar.toArray(new String[0])); listPreference.setEntryValues(val.toArray(new String[0])); } }
private void setListPreferenceIconsPacksData(ListPreference lp) { IconsHandler iph = KissApplication.getApplication(this).getIconsHandler(); CharSequence[] entries = new CharSequence[iph.getIconsPacks().size() + 1]; CharSequence[] entryValues = new CharSequence[iph.getIconsPacks().size() + 1]; int i = 0; entries[0] = this.getString(R.string.icons_pack_default_name); entryValues[0] = "default"; for (String packageIconsPack : iph.getIconsPacks().keySet()) { entries[++i] = iph.getIconsPacks().get(packageIconsPack); entryValues[i] = packageIconsPack; } lp.setEntries(entries); lp.setDefaultValue("default"); lp.setEntryValues(entryValues); }
activity.runOnUiThread(() -> { listPreference.setEntries(entries); listPreference.setEntryValues(entries); });
@SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { // update settings with actual device admin setting /*mDPM = (DevicePolicyManager) this.getActivity().getSystemService( Context.DEVICE_POLICY_SERVICE); deviceAdmin = new ComponentName(this.getActivity() .getApplicationContext(), AdminDeviceReceiver.class);*/ super.onCreate(savedInstanceState); globalContext = this.getActivity(); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.security_preferences); //backward compatibility preSelectListForBackward(); setupDeviceSecurityCheck(findPreference("enableDeviceCheck")); //setupEnableAdmin(findPreference("enableAdmin")); //passOption = G.protectionLevel(); // Hide Fingerprint option if device not support it. if (!FingerprintUtil.isAndroidSupport() || !canUserFingerPrint()) { ListPreference itemList = (ListPreference) findPreference("passSetting"); itemList.setEntries(new String[]{ getString(R.string.pref_none), getString(R.string.pref_password), getString(R.string.pref_pattern), }); itemList.setEntryValues(new String[]{ "p0", "p1", "p2" }); } }
private void preSelectListForBackward() { final ListPreference itemList = (ListPreference) findPreference("passSetting"); //remove other option if (Build.VERSION.SDK_INT < 21) { itemList.setEntries(itemList.getEntries()); itemList.setEntryValues(itemList.getEntryValues()); } if (itemList != null) { switch (G.protectionLevel()) { case "p0": itemList.setValueIndex(0); break; case "p1": itemList.setValueIndex(1); break; case "p2": itemList.setValueIndex(2); break; case "p3": itemList.setValueIndex(3); break; case "Disable": itemList.setValueIndex(0); break; default: itemList.setValueIndex(0); break; } } }
primaryServer.setEntryValues(DNSServerHelper.getIds()); primaryServer.setSummary(DNSServerHelper.getDescription(primaryServer.getValue(), Daedalus.getInstance())); primaryServer.setOnPreferenceChangeListener((preference, newValue) -> { secondaryServer.setEntryValues(DNSServerHelper.getIds()); secondaryServer.setSummary(DNSServerHelper.getDescription(secondaryServer.getValue(), Daedalus.getInstance())); secondaryServer.setOnPreferenceChangeListener((preference, newValue) -> {