List of usage examples for android.preference ListPreference setEntryValues
public void setEntryValues(@ArrayRes int entryValuesResId)
From source file:Main.java
public static void PopulateList(Preference preference, String[] List) { ListPreference PrefList = (ListPreference) preference; if (List == null) { PrefList.setEnabled(false);/*from w w w. j av a 2 s. co m*/ } else { PrefList.setEntryValues(List); PrefList.setEntries(List); PrefList.setEnabled(true); } }
From source file:Main.java
public static void removeListPrefItems(ListPreference listPref, String[] labels, String[] values, List<String> items) { List<String> labelsList = new ArrayList<String>(Arrays.asList(labels)); List<String> valuesList = new ArrayList<String>(Arrays.asList(values)); Iterator<String> it = valuesList.iterator(); while (it.hasNext()) { String value = it.next(); if (items.contains(value)) { labelsList.remove(valuesList.indexOf(value)); it.remove();/*w w w . java 2 s . c o m*/ } } listPref.setEntries(labelsList.toArray(new String[1])); listPref.setEntryValues(valuesList.toArray(new String[1])); }
From source file:Main.java
public static void markItemsAsPro(ListPreference listPref, String[] labels, String[] values, List<String> proItems, String proWord) { List<String> labelsList = new ArrayList<String>(Arrays.asList(labels)); List<String> valuesList = new ArrayList<String>(Arrays.asList(values)); Iterator<String> it = valuesList.iterator(); for (int i = 0; i < valuesList.size(); i++) { String value = valuesList.get(i); String label = labelsList.get(i); if (proItems.contains(value)) { labelsList.set(i, label + " " + proWord); }// w ww. ja v a2s .c o m } listPref.setEntries(labelsList.toArray(new String[1])); listPref.setEntryValues(valuesList.toArray(new String[1])); }
From source file:co.taqat.call.AccountPreferencesFragment.java
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) { CharSequence[] contents = new CharSequence[entries.size()]; entries.toArray(contents);/*w w w . j a va 2 s .c om*/ pref.setEntries(contents); contents = new CharSequence[values.size()]; values.toArray(contents); pref.setEntryValues(contents); }
From source file:ru.sash0k.thriftbox.fragments.SettingsFragment.java
/** * ??// w w w.j a v a2s .co m */ private void getListValues(String tag, int titlesId, int valuesId) { ListPreference listprefence = (ListPreference) findPreference(tag); if (listprefence != null) { listprefence.setEntries(titlesId); listprefence.setEntryValues(valuesId); } setPrefenceTitle(tag); }
From source file:com.airflo.preferences.ListPreferenceActivity.java
/** * Add one slider preference to the category. * @param cat/*from w w w . ja va2s . c om*/ * @param key * @param title */ private void addOneListItem(PreferenceCategory cat, String key, String title) { final ListPreference listPref = new ListPreference(this); listPref.setKey(key); listPref.setEntries(FlightData.identis.getPrefListChars(true)); listPref.setEntryValues(FlightData.identis.getPrefListChars(false)); listPref.setDialogTitle(title); listPref.setSummary( FlightData.identis.getIdenti(root.getSharedPreferences().getString(key, "empty")).getStringRep()); listPref.setTitle(title); cat.addPreference(listPref); listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { listPref.setSummary(FlightData.identis.getIdenti((String) newValue).getStringRep()); return true; } }); }
From source file:com.airflo.preferences.ListPreferenceActivity.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override//www. j av a2 s.com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } root = getPreferenceManager().createPreferenceScreen(this); //Array of sorting preference keys to be included. //SortType must be specified in bookitems.xml! String[] sortValues = new String[] { "number", "date;starttime", "site;date;starttime", "duration", "maxheight", "maxvario", "starttype;date;starttime" }; //Generate according Entry Strings. String[] sortEntries = new String[sortValues.length]; for (int i = 0; i < sortEntries.length; i++) sortEntries[i] = sortKeyToString(sortValues[i]); //Make sorting category PreferenceCategory cat = new PreferenceCategory(this); cat.setTitle(R.string.list_pref_cat_sort_title); root.addPreference(cat); final ListPreference listPref = new ListPreference(this); listPref.setKey("list_pref_sort"); listPref.setEntries(sortEntries); listPref.setEntryValues(sortValues); listPref.setDialogTitle(R.string.list_pref_sort_criterium); listPref.setSummary(sortKeyToString(root.getSharedPreferences().getString("list_pref_sort", "number"))); listPref.setTitle(R.string.list_pref_sort_criterium); cat.addPreference(listPref); listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { listPref.setSummary(sortKeyToString((String) newValue)); return true; } }); final ListPreference orderPref = new ListPreference(this); orderPref.setKey("list_pref_order"); orderPref.setEntries(new String[] { OnlyContext.rString("list_pref_sort_ascending"), OnlyContext.rString("list_pref_sort_decending") }); orderPref.setEntryValues(new String[] { "list_pref_sort_ascending", "list_pref_sort_decending" }); orderPref.setDialogTitle(R.string.list_pref_sort_sequence); orderPref.setSummary(OnlyContext .rString(root.getSharedPreferences().getString("list_pref_order", "list_pref_sort_decending"))); orderPref.setTitle(R.string.list_pref_sort_sequence); cat.addPreference(orderPref); orderPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { orderPref.setSummary(OnlyContext.rString((String) newValue)); return true; } }); //Make item categories addManyListItems(R.string.list_pref_cat1_title, "listhead", 3); addManyListItems(R.string.list_pref_cat2_title, "listsub", 3); this.setPreferenceScreen(root); }
From source file:org.dmfs.webcal.fragments.PreferencesFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.webcal_preference); ListPreference locales = (ListPreference) findPreference("content_location"); locales.setOnPreferenceChangeListener(PrefUpdater); try {// ww w . j a v a2 s .c o m getCountries(); locales.setEntries(mCountryNames); locales.setEntryValues(mCountryCodes); } catch (Exception e) { Log.e(TAG, "could not load country list", e); } int index = locales.findIndexOfValue(locales.getValue()); if (index >= 0) { locales.setSummary(locales.getEntries()[index]); } else { locales.setSummary(locales.getEntries()[0]); locales.setValueIndex(0); } }
From source file:com.schoentoon.connectbot.HostEditorActivity.java
private void initCharsetPref(final ListPreference charsetPref) { charsetPref.setEntryValues(CharsetHolder.getCharsetIds()); charsetPref.setEntries(CharsetHolder.getCharsetNames()); }
From source file:org.linphone.SettingsFragment.java
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) { CharSequence[] contents = new CharSequence[entries.size()]; entries.toArray(contents);/* www . j a v a2 s .c o m*/ if (pref != null) { pref.setEntries(contents); contents = new CharSequence[values.size()]; values.toArray(contents); pref.setEntryValues(contents); } }