List of usage examples for android.preference ListPreference setEntries
public void setEntries(@ArrayRes int entriesResId)
From source file:com.hichinaschool.flashcards.anki.Preferences.java
/** Initializes the list of custom fonts shown in the preferences. */ private void initializeCustomFontsDialog() { ListPreference customFontsPreference = (ListPreference) getPreferenceScreen().findPreference("defaultFont"); customFontsPreference.setEntries(getCustomFonts("System default")); customFontsPreference.setEntryValues(getCustomFonts("")); ListPreference browserEditorCustomFontsPreference = (ListPreference) getPreferenceScreen() .findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
From source file:com.schoentoon.connectbot.HostEditorActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getSupportActionBar().setSubtitle("Host editor"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); long hostId = this.getIntent().getLongExtra(Intent.EXTRA_TITLE, -1); // TODO: we could pass through a specific ContentProvider uri here //this.getPreferenceManager().setSharedPreferencesName(uri); this.hostdb = new HostDatabase(this); this.pubkeydb = new PubkeyDatabase(this); host = hostdb.findHostById(hostId);//from ww w .ja v a2 s. c o m connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService(); hostBridge = bound.getConnectedBridge(host); } public void onServiceDisconnected(ComponentName name) { hostBridge = null; } }; this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId); this.pref.registerOnSharedPreferenceChangeListener(this); this.addPreferencesFromResource(R.xml.host_prefs); // add all existing pubkeys to our listpreference for user to choose from // TODO: may be an issue here when this activity is recycled after adding a new pubkey // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once ListPreference pubkeyPref = (ListPreference) this.findPreference(HostDatabase.FIELD_HOST_PUBKEYID); List<CharSequence> pubkeyNicks = new LinkedList<CharSequence>(Arrays.asList(pubkeyPref.getEntries())); pubkeyNicks.addAll(pubkeydb.allValues(PubkeyDatabase.FIELD_PUBKEY_NICKNAME)); pubkeyPref.setEntries(pubkeyNicks.toArray(new CharSequence[pubkeyNicks.size()])); List<CharSequence> pubkeyIds = new LinkedList<CharSequence>(Arrays.asList(pubkeyPref.getEntryValues())); pubkeyIds.addAll(pubkeydb.allValues("_id")); pubkeyPref.setEntryValues(pubkeyIds.toArray(new CharSequence[pubkeyIds.size()])); // Populate the character set encoding list with all available final ListPreference charsetPref = (ListPreference) findPreference(HostDatabase.FIELD_HOST_ENCODING); if (CharsetHolder.isInitialized()) { initCharsetPref(charsetPref); } else { String[] currentCharsetPref = new String[1]; currentCharsetPref[0] = charsetPref.getValue(); charsetPref.setEntryValues(currentCharsetPref); charsetPref.setEntries(currentCharsetPref); new Thread(new Runnable() { public void run() { initCharsetPref(charsetPref); } }).start(); } this.updateSummaries(); }
From source file:net.naonedbus.activity.impl.OldSettingsActivity.java
/** * Lister les calendrier dans la ListPreference passe en paramtre * /* ww w . j a v a 2s.c o m*/ * @param list */ private void fillCalendars(final ListPreference list) { CharSequence[] entriesName; CharSequence[] entriesId; final Map<Integer, String> calendars = CalendarUtils.getCalendars(getContentResolver()); entriesName = new String[calendars.size()]; entriesId = new String[calendars.size()]; int i = 0; for (final Entry<Integer, String> cal : calendars.entrySet()) { entriesName[i] = cal.getValue(); entriesId[i++] = String.valueOf(cal.getKey()); } list.setEntries(entriesName); list.setEntryValues(entriesId); }
From source file:net.naonedbus.fragment.impl.SettingsFragment.java
/** * Lister les calendrier dans la ListPreference passe en paramtre. * //from w w w. ja va 2 s . c o m * @param list */ private void fillCalendars(final ListPreference list) { CharSequence[] entriesName; CharSequence[] entriesId; final Map<Integer, String> calendars = CalendarUtils.getCalendars(getActivity().getContentResolver()); entriesName = new String[calendars.size()]; entriesId = new String[calendars.size()]; int i = 0; for (final Entry<Integer, String> cal : calendars.entrySet()) { entriesName[i] = cal.getValue(); entriesId[i++] = String.valueOf(cal.getKey()); } list.setEntries(entriesName); list.setEntryValues(entriesId); }
From source file:com.android.leanlauncher.SettingsActivity.java
private void displayIconThemePref(ListPreference lpIconSetting) { ArrayMap<String, String> iconPacks = LauncherAppState.getInstance().getIconCache().getAvailableIconPacks(); if (iconPacks != null && iconPacks.size() != 0) { String iconPackValues[] = iconPacks.keySet().toArray(new String[iconPacks.size() + 1]); iconPackValues[iconPacks.size()] = ""; String[] iconPackTitles = new String[iconPacks.size() + 1]; for (int i = 0; i < iconPacks.size(); i++) { iconPackTitles[i] = iconPacks.get(iconPacks.keyAt(i)); }//from ww w.j a v a2 s . co m iconPackTitles[iconPacks.size()] = getString(R.string.pref_no_icon_theme); lpIconSetting.setEntries(iconPackTitles); lpIconSetting.setEntryValues(iconPackValues); } else { lpIconSetting.setEnabled(false); lpIconSetting.setShouldDisableView(true); lpIconSetting.setSummary(R.string.pref_icon_theme_summary_disabled); } }
From source file:com.ichi2.anki.PreferenceContext.java
/** 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("")); }//from ww w . ja v a2s .c o m ListPreference browserEditorCustomFontsPreference = (ListPreference) screen .findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
From source file:org.span.manager.ChangeSettingsActivity.java
private void updateView() { // user id//from ww w.j a v a2s. co m EditTextPreference uidEditTextPref = (EditTextPreference) findPreference("uidpref"); uidEditTextPref.setText(manetcfg.getUserId()); // wifi group wifiGroupPref = (PreferenceGroup) findPreference("wifiprefs"); boolean bluetoothOn = manetcfg.isUsingBluetooth(); wifiGroupPref.setEnabled(!bluetoothOn); // wifi encryption algorithm WifiEncryptionAlgorithmEnum encAlgorithm = manetcfg.getWifiEncryptionAlgorithm(); ListPreference wifiEncAlgorithmPref = (ListPreference) findPreference("encalgorithmpref"); wifiEncAlgorithmPref.setEnabled(false); // TODO: disable until tested wifiEncAlgorithmPref.setEntries(WifiEncryptionAlgorithmEnum.descriptionValues()); wifiEncAlgorithmPref.setEntryValues(WifiEncryptionAlgorithmEnum.stringValues()); wifiEncAlgorithmPref.setValueIndex(encAlgorithm.ordinal()); // wifi encryption setup method ListPreference wifiEncSetupMethodPref = (ListPreference) findPreference("encsetuppref"); wifiEncSetupMethodPref.setEnabled(false); // TODO: disable until tested if (encAlgorithm == WifiEncryptionAlgorithmEnum.NONE) { wifiEncSetupMethodPref.setEnabled(false); } else { wifiEncSetupMethodPref.setEnabled(true); if (manetcfg.getWifiDriver().startsWith("softap") || manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { if (wifiEncSetupMethodPref != null) { wifiGroupPref.removePreference(wifiEncSetupMethodPref); } } else { wifiEncSetupMethodPref.setEntries(WifiEncryptionSetupMethodEnum.descriptionValues()); wifiEncSetupMethodPref.setEntryValues(WifiEncryptionSetupMethodEnum.stringValues()); wifiEncSetupMethodPref.setValueIndex(manetcfg.getWifiEncryptionSetupMethod().ordinal()); } } // wifi encryption password final EditTextPreference wifiEncPasswordEditTextPref = (EditTextPreference) findPreference("passwordpref"); wifiEncPasswordEditTextPref.setEnabled(false); // TODO: disable until tested if (encAlgorithm == WifiEncryptionAlgorithmEnum.NONE) { wifiEncPasswordEditTextPref.setEnabled(false); } else { wifiEncPasswordEditTextPref.setEnabled(true); final int origTextColorWifiEncKey = wifiEncPasswordEditTextPref.getEditText().getCurrentTextColor(); if (manetcfg.getWifiDriver().startsWith("softap") || manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { Validation.setupWpaEncryptionValidators(wifiEncPasswordEditTextPref, origTextColorWifiEncKey); } else { Validation.setupWepEncryptionValidators(wifiEncPasswordEditTextPref, origTextColorWifiEncKey); } wifiEncPasswordEditTextPref.setText(manetcfg.getWifiEncryptionPassword()); } // wifi SSID EditTextPreference wifiSsidEditTextPref = (EditTextPreference) findPreference("ssidpref"); Validation.setupWifiSsidValidator(wifiSsidEditTextPref); wifiSsidEditTextPref.setText(manetcfg.getWifiSsid()); // wifi channel ListPreference channelpref = (ListPreference) findPreference("channelpref"); channelpref.setEnabled(false); // TODO: disable until tested String[] channelStrValues = WifiChannelEnum.stringValues(); String[] channelDescValues = WifiChannelEnum.descriptionValues(); // remove auto channel option if not supported by device if (!manetcfg.getWifiDriver().startsWith("softap") || !manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { // auto channel option at first index String[] newChannelStrValues = new String[channelStrValues.length - 1]; String[] newChannelDescValues = new String[channelStrValues.length - 1]; for (int i = 1; i < channelStrValues.length; i++) { newChannelStrValues[i - 1] = channelStrValues[i]; newChannelDescValues[i - 1] = channelDescValues[i]; } channelpref.setEntries(newChannelDescValues); channelpref.setEntryValues(newChannelStrValues); WifiChannelEnum wifiChannel = manetcfg.getWifiChannel(); if (wifiChannel == WifiChannelEnum.AUTO) { channelpref.setValueIndex(WifiChannelEnum.CHANNEL_1.ordinal() - 1); } else { channelpref.setValueIndex(wifiChannel.ordinal() - 1); } } else { channelpref.setEntries(channelDescValues); channelpref.setEntryValues(channelStrValues); channelpref.setValueIndex(manetcfg.getWifiChannel().ordinal()); } // wifi transmit power ListPreference txpowerPreference = (ListPreference) findPreference("txpowerpref"); if (!manetcfg.isTransmitPowerSupported()) { // DEBUG if (txpowerPreference != null) { wifiGroupPref.removePreference(txpowerPreference); } } else { txpowerPreference.setEntries(WifiTxpowerEnum.descriptionValues()); txpowerPreference.setEntryValues(WifiTxpowerEnum.stringValues()); txpowerPreference.setValueIndex(manetcfg.getWifiTxpower().ordinal()); } // bluetooth group // disable bluetooth adhoc if not supported by the kernel if (true) { // !manetcfg.isBluetoothSupported() // TODO: disable until tested PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); btGroup.setEnabled(false); } // bluetooth // NOTE: bluetooth dependencies are specified in the layout XML // CheckBoxPreference bluetoothCheckboxPref = (CheckBoxPreference)findPreference("bluetoothonpref"); // bluetooth keep wifi CheckBoxPreference btKeepWifiCheckBoxPref = (CheckBoxPreference) findPreference("bluetoothkeepwifipref"); if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.ECLAIR) { PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); if (btKeepWifiCheckBoxPref != null) { btGroup.removePreference(btKeepWifiCheckBoxPref); } } else { btKeepWifiCheckBoxPref.setChecked(!manetcfg.isWifiDisabledWhenUsingBluetooth()); } // bluetooth discoverable CheckBoxPreference btdiscoverablePreference = (CheckBoxPreference) findPreference( "bluetoothdiscoverablepref"); if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.ECLAIR) { PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); if (btdiscoverablePreference != null) { btGroup.removePreference(btdiscoverablePreference); } } else { btdiscoverablePreference.setChecked(manetcfg.isBluetoothDiscoverableWhenInAdhocMode()); } // ip address EditTextPreference ipAddressEditTextPref = (EditTextPreference) findPreference("ippref"); Validation.setupIpAddressValidator(ipAddressEditTextPref); ipAddressEditTextPref.setText(manetcfg.getIpAddress()); // dns server EditTextPreference dnsServerEditTextPref = (EditTextPreference) findPreference("dnspref"); Validation.setupIpAddressValidator(dnsServerEditTextPref); dnsServerEditTextPref.setText(manetcfg.getDnsServer()); // routing protocol String currRoutingProtocol = manetcfg.getRoutingProtocol(); List<String> routingProtocolList = CoreTask.getRoutingProtocols(); String[] routingProtocols = new String[routingProtocolList.size()]; routingProtocolList.toArray(routingProtocols); ListPreference routingProtocolPreference = (ListPreference) findPreference("routingprotocolpref"); routingProtocolPreference.setEntries(routingProtocols); routingProtocolPreference.setEntryValues(routingProtocols); routingProtocolPreference.setValue(currRoutingProtocol); // routing ignore list JSONArray array = new JSONArray(manetcfg.getRoutingIgnoreList()); sharedPreferences.edit().putString("ignorepref", array.toString()).commit(); // wifi interface String currInterface = manetcfg.getWifiInterface(); String defaultInterface = DeviceConfig.getWifiInterface(manetcfg.getDeviceType()); List<String> interfaceList = CoreTask.getNetworkInterfaces(); if (!interfaceList.contains(defaultInterface)) { interfaceList.add(defaultInterface); } String[] interfaces = new String[interfaceList.size()]; interfaceList.toArray(interfaces); ListPreference interfacePreference = (ListPreference) findPreference("interfacepref"); interfacePreference.setEntries(interfaces); interfacePreference.setEntryValues(interfaces); if (interfaceList.contains(currInterface)) { interfacePreference.setValue(currInterface); } else { interfacePreference.setValue(defaultInterface); currInterface = defaultInterface; } // routing gateway String currGatewayInterface = manetcfg.getGatewayInterface(); interfaceList.remove(currInterface); // remove ad-hoc interface interfaceList.add(0, ManetConfig.GATEWAY_INTERFACE_NONE); interfaces = new String[interfaceList.size()]; interfaceList.toArray(interfaces); ListPreference gatewayPreference = (ListPreference) findPreference("gatewaypref"); gatewayPreference.setEntries(interfaces); gatewayPreference.setEntryValues(interfaces); gatewayPreference.setValue(currGatewayInterface); if (interfaceList.contains(currGatewayInterface)) { gatewayPreference.setValue(currGatewayInterface); } else { gatewayPreference.setValue(ManetConfig.GATEWAY_INTERFACE_NONE); } // screen on CheckBoxPreference screenOnPreference = (CheckBoxPreference) findPreference("screenonpref"); screenOnPreference.setChecked(manetcfg.isScreenOnWhenInAdhocMode()); // battery temperature setupFlag = true; }
From source file:com.nttec.everychan.chans.dobrochan.DobroModule.java
private void addRatingPreference(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateRatingListener = new Preference.OnPreferenceChangeListener() { @Override/*w w w . j a va 2 s . c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_MAX_RATING))) { setMaxRating((String) newValue); return true; } return false; } }; ListPreference ratingPref = new LazyPreferences.ListPreference(context); ratingPref.setTitle(R.string.dobrochan_prefs_max_rating); ratingPref.setSummary(preferences.getString(getSharedKey(PREF_KEY_MAX_RATING), "R-15")); ratingPref.setEntries(RATINGS); ratingPref.setEntryValues(RATINGS); ratingPref.setDefaultValue("R-15"); ratingPref.setKey(getSharedKey(PREF_KEY_MAX_RATING)); ratingPref.setOnPreferenceChangeListener(updateRatingListener); group.addPreference(ratingPref); }
From source file:org.tvheadend.tvhclient.fragments.SettingsProfileFragment.java
/** * //from ww w. ja va 2s . c om * @param preferenceList * @param profileList */ protected void addProfiles(ListPreference preferenceList, final List<Profiles> profileList) { // Initialize the arrays that contain the profile values final int size = profileList.size(); CharSequence[] entries = new CharSequence[size]; CharSequence[] entryValues = new CharSequence[size]; // Add the available profiles to list preference for (int i = 0; i < size; i++) { entries[i] = profileList.get(i).name; entryValues[i] = profileList.get(i).uuid; } preferenceList.setEntries(entries); preferenceList.setEntryValues(entryValues); // Enable the preference for use selection preferenceList.setEnabled(true); }
From source file:com.bellman.bible.android.view.activity.settings.SettingsActivity.java
private void addScreenTimeoutSettings() { ListPreference timeoutPref = (ListPreference) getPreferenceScreen() .findPreference(ScreenTimeoutSettings.SCREEN_TIMEOUT_PREF); timeoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override/*from w w w . j a v a 2 s . c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { // update screen timeout try { if (StringUtils.isNotEmpty((String) newValue)) { ScreenTimeoutSettings.setScreenTimeout(Integer.parseInt((String) newValue)); } } catch (Exception e) { Log.e(TAG, "Error updating timeout set in preference screen", e); } return true; } }); ScreenTimeoutSettings screenTimeoutSettings = new ScreenTimeoutSettings(); timeoutPref.setEntries(screenTimeoutSettings.getPreferenceEntries()); timeoutPref.setEntryValues(screenTimeoutSettings.getPreferenceEntryValues()); }