本文整理汇总了Java中android.preference.MultiSelectListPreference.setEntryValues方法的典型用法代码示例。如果您正苦于以下问题:Java MultiSelectListPreference.setEntryValues方法的具体用法?Java MultiSelectListPreference.setEntryValues怎么用?Java MultiSelectListPreference.setEntryValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.MultiSelectListPreference
的用法示例。
在下文中一共展示了MultiSelectListPreference.setEntryValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupWeekDaysPref
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void setupWeekDaysPref() {
mPrefWeekDays = (MultiSelectListPreference) findPreference(PREF_KEY_QH_WEEKDAYS);
String[] days = new DateFormatSymbols(Locale.getDefault()).getWeekdays();
CharSequence[] entries = new CharSequence[7];
CharSequence[] entryValues = new CharSequence[7];
for (int i = 1; i <= 7; i++) {
entries[i - 1] = days[i];
entryValues[i - 1] = String.valueOf(i);
}
mPrefWeekDays.setEntries(entries);
mPrefWeekDays.setEntryValues(entryValues);
if (mPrefs.getStringSet(PREF_KEY_QH_WEEKDAYS, null) == null) {
Set<String> value = new HashSet<String>(Arrays.asList("2", "3", "4", "5", "6"));
mPrefs.edit().putStringSet(PREF_KEY_QH_WEEKDAYS, value).commit();
mPrefWeekDays.setValues(value);
}
}
示例2: onCreate
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_scanning);
bindPreferenceToSummary();
setOnPreferenceClickListeners();
beaconFormatList = new HashSet<>();
sharedPreferences = getPreferenceManager().getSharedPreferences();
MultiSelectListPreference list = (MultiSelectListPreference) getPreferenceManager().findPreference("key_beacon_formats");
Set<String> beaconFormats = sharedPreferences.getStringSet("key_beacon_formats", beaconFormatList);
CharSequence[] sequences = beaconFormats.toArray(new CharSequence[beaconFormats.size()]);
list.setEntries(sequences);
list.setEntryValues(sequences);
}
示例3: setupElmCmdSelection
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
/**
* set up protocol selection
*/
void setupElmCmdSelection()
{
MultiSelectListPreference pref =
(MultiSelectListPreference) findPreference(ELM_CMD_DISABLE);
ElmProt.CMD[] values = ElmProt.CMD.values();
HashSet<String> selections = new HashSet<String>();
CharSequence[] titles = new CharSequence[values.length];
CharSequence[] keys = new CharSequence[values.length];
int i = 0;
for (ElmProt.CMD cmd : values)
{
titles[i] = cmd.toString();
keys[i] = cmd.toString();
if(!cmd.isEnabled()) selections.add(cmd.toString());
i++;
}
// set enries and keys
pref.setEntries(titles);
pref.setEntryValues(keys);
pref.setValues(selections);
}
示例4: loadGroup
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void loadGroup() {
// Consider adding more features here, such as those in Track and TrackPreferenceFragment
name = (EditTextPreference) findPreference("name");
name.setText(group.getName());
name.setSummary(group.getName());
description = (EditTextPreference) findPreference("description");
description.setText(group.getDescription());
description.setSummary(group.getDescription());
mTracksPref = (MultiSelectListPreference) findPreference("tracks");
mTracksPref.setValues(getTrackIdsForGroupAsSet(group.getId()));
mTracksPref.setEntries(getAllTrackNamesAsCharSeq());
mTracksPref.setEntryValues(getAllTrackIdsAsCharSeq());
mTracksPref.setSummary(getTrackNamesForSummary());
}
示例5: setUpUnitTypePrefs
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
/**
* Helper Class to setup the default Unit Type preference list in code
*/
private void setUpUnitTypePrefs() {
PreferenceScreen screen = getPreferenceScreen();
MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity());
listPref.setOrder(0);
listPref.setDialogTitle(R.string.unit_select_title);
listPref.setKey(UNIT_TYPE_PREF_KEY);
listPref.setSummary(R.string.unit_select_summary);
listPref.setTitle(R.string.unit_select_title);
listPref.setEntries(getUnitTypeNameArray(getResources()));
String[] keyArray = getUnitTypeKeyArray(getResources());
listPref.setEntryValues(keyArray);
final Set<String> result = new HashSet<>();
Collections.addAll(result, keyArray);
listPref.setDefaultValue(result);
screen.addPreference(listPref);
}
示例6: onCreate
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.settings_preferences);
mMultiSelectListPreference = (MultiSelectListPreference) findPreference("select_apply_on_boot");
ArrayList<CharSequence> entries = new ArrayList<>();
entries.add(getString(R.string.cpu_frequency));
if (GpuUtils.isGpuFrequencyScalingSupported()) {
entries.add(getString(R.string.gpu_frequency));
}
entries.add(getString(R.string.io));
entries.add(getString(R.string.build_prop));
entries.add(getString(R.string.vm));
CharSequence[] charSequences = new CharSequence[entries.size()];
for (int i = 0; i < entries.size(); i++) {
charSequences[i] = entries.get(i);
}
mMultiSelectListPreference.setEntries(charSequences);
mMultiSelectListPreference.setEntryValues(charSequences);
}
示例7: onCreate
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.notification_settings);
setHasOptionsMenu(true);
final Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context
.VIBRATOR_SERVICE);
if (!vibrator.hasVibrator()) {
final MultiSelectListPreference inAppSettings = (MultiSelectListPreference)
findPreference(PREF_IN_APP_NOTIFICATION_SETTINGS);
final MultiSelectListPreference outOfAppSettings = (MultiSelectListPreference)
findPreference(PREF_OUT_OF_APP_NOTIFICATION_SETTINGS);
inAppSettings.setEntries(R.array.notification_in_entries_no_vibrator);
inAppSettings.setEntryValues(R.array.notification_in_values_no_vibrator);
outOfAppSettings.setEntries(R.array.notification_out_entries_no_vibrator);
outOfAppSettings.setEntryValues(R.array.notification_out_values_no_vibrator);
}
}
示例8: onCreate
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
//dynamically populate this with the databases available
final DatabaseHelper dbHelper = new DatabaseHelper(getActivity());
dbHelper.gatherFiles();
final Set<String> mDBList = dbHelper.GetListofDB();
MultiSelectListPreference myMultPref = (MultiSelectListPreference) findPreference(getString(R.string.pref_dbs));
if (myMultPref != null) {
CharSequence entries[] = new String[mDBList.size()];
CharSequence entryValues[] = new String[mDBList.size()];
int i = 0;
for (String str : mDBList) {
entries[i] = str;
entryValues[i] = str;
i++;
}
myMultPref.setEntries(entries);
myMultPref.setEntryValues(entryValues);
}
}
示例9: loadWasteStreamSettings
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
public void loadWasteStreamSettings(){
final MultiSelectListPreference streamPrefs = (MultiSelectListPreference) findPreference(WeightRecorder.PREF_WASTE_STREAMS);
WasteStreams wasteStreams = new WasteStreams();
wasteStreams.loadWasteStreams(getActivity().getApplicationContext());
streamPrefs.setDefaultValue(wasteStreams.getDefaultStreamValues());
streamPrefs.setEntries(wasteStreams.getAllStreamNames());
streamPrefs.setEntryValues(wasteStreams.getAllStreamValues());
bindPreferenceSummaryToValue(streamPrefs);
}
示例10: reloadLogsFilter
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void reloadLogsFilter() {
MultiSelectListPreference logsFilter = (MultiSelectListPreference) findPreference("logs_filter_manage");
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
Set<String> items = prefs.getStringSet(LOGS_FILTER_MANAGE,
new HashSet<String>());
CharSequence[] logsFilterItems = items.toArray(new CharSequence[items
.size()]);
logsFilter.setEntries(logsFilterItems);
logsFilter.setEntryValues(logsFilterItems);
}
示例11: multi
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private MultiSelectListPreference multi() {
MultiSelectListPreference pref = new MultiSelectListPreference(a);
pref.setKey(MULTI);
pref.setEntries(new String[]{"One", "Two", "Three"});
pref.setEntryValues(new String[]{"1", "2", "3"});
return pref;
}
示例12: fillBuckets
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void fillBuckets() {
this.bucketNames = PBApplication.getMediaStore().getBucketData();
final CharSequence[] ids = this.bucketNames.values().toArray(new CharSequence[this.bucketNames.size()]);
final CharSequence[] names = this.bucketNames.keySet().toArray(new CharSequence[this.bucketNames.size()]);
final MultiSelectListPreference bucketListPreference = (MultiSelectListPreference) findPreference(PBConstants.PREF_PICTURE_FOLDER_LIST);
bucketListPreference.setEntries(ids);
bucketListPreference.setEnabled(true);
bucketListPreference.setEntryValues(names);
setSummaries();
}
示例13: setupPidSelection
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
/**
* set up selection for PIDs
*/
void setupPidSelection()
{
MultiSelectListPreference itemList =
(MultiSelectListPreference) findPreference(KEY_DATA_ITEMS);
// collect data items for selection
items = ObdProt.dataItems.getSvcDataItems(ObdProt.OBD_SVC_DATA);
HashSet<String> selections = new HashSet<String>();
CharSequence[] titles = new CharSequence[items.size()];
CharSequence[] keys = new CharSequence[items.size()];
// loop through data items
int i = 0;
for (EcuDataItem currItem : items)
{
titles[i] = currItem.label;
keys[i] = currItem.toString();
selections.add(currItem.toString());
i++;
}
// set enries and keys
itemList.setEntries(titles);
itemList.setEntryValues(keys);
// if there is no item selected, mark all as selected
if (itemList.getValues().size() == 0)
{
itemList.setValues(selections);
}
}
示例14: addAccountsPreference
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void addAccountsPreference() {
final String[] accounts = GmailExtension.getAllAccountNames(this);
Set<String> allAccountsSet = new HashSet<String>();
allAccountsSet.addAll(Arrays.asList(accounts));
MultiSelectListPreference accountsPreference = new MultiSelectListPreference(this);
accountsPreference.setKey(GmailExtension.PREF_ACCOUNTS);
accountsPreference.setTitle(R.string.pref_gmail_accounts_title);
accountsPreference.setEntries(accounts);
accountsPreference.setEntryValues(accounts);
accountsPreference.setDefaultValue(allAccountsSet);
mFragment.getPreferenceScreen().addPreference(accountsPreference);
Preference.OnPreferenceChangeListener accountsChangeListener
= new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
int numSelected = 0;
int numTotal = accounts.length;
try {
//noinspection unchecked
Set<String> selectedAccounts = (Set<String>) value;
if (selectedAccounts != null) {
numSelected = selectedAccounts.size();
}
} catch (ClassCastException ignored) {
}
preference.setSummary(getResources().getQuantityString(
R.plurals.pref_gmail_accounts_summary_template,
numTotal, numSelected, numTotal));
return true;
}
};
accountsPreference.setOnPreferenceChangeListener(accountsChangeListener);
accountsChangeListener.onPreferenceChange(accountsPreference,
PreferenceManager
.getDefaultSharedPreferences(this)
.getStringSet(accountsPreference.getKey(), allAccountsSet));
}
示例15: onCreate
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SettingsActivityComponent cmp = DaggerService.getDaggerComponent(getActivity());
cmp.inject(this);
mSettings.setCached(true);
addPreferencesFromResource(R.xml.prefs_service);
runWhen = (ListPreference) findPreference(ServiceSettings.RUN_WHEN);
runWhen.setPersistent(false);
runWhen.setValue(mSettings.runWhen());
runWhen.setOnPreferenceChangeListener(this);
onlyOnWifi = (CheckBoxPreference) findPreference(ServiceSettings.ONLY_WIFI);
onlyOnWifi.setPersistent(false);
onlyOnWifi.setChecked(mSettings.onlyOnWifi());
onlyOnWifi.setOnPreferenceChangeListener(this);
wifiNetwork = (MultiSelectListPreference) findPreference(ServiceSettings.WIFI_NETWORKS);
wifiNetwork.setPersistent(false);
String[] ssids = getWifiNetworks();
wifiNetwork.setEntries(ssids);
wifiNetwork.setEntryValues(ssids);
wifiNetwork.setValues(mSettings.allowedWifiNetworks());
wifiNetwork.setOnPreferenceChangeListener(this);
onlyCharging = (CheckBoxPreference) findPreference(ServiceSettings.ONLY_CHARGING);
onlyCharging.setPersistent(false);
onlyCharging.setChecked(mSettings.onlyWhenCharging());
onlyCharging.setOnPreferenceChangeListener(this);
catBetween = (PreferenceCategory) findPreference("cat_between");
hideShowRunWhenCategories(mSettings.runWhen());
scheduleStart = (TimePreference) findPreference(ServiceSettings.RANGE_START);
scheduleStart.setPersistent(false);
scheduleStart.setValue(mSettings.getScheduledStartTime());
scheduleStart.setOnPreferenceChangeListener(this);
scheduleEnd = (TimePreference) findPreference(ServiceSettings.RANGE_END);
scheduleEnd.setPersistent(false);
scheduleEnd.setValue(mSettings.getScheduledEndTime());
scheduleEnd.setOnPreferenceChangeListener(this);
exportConfig = findPreference("export");
exportConfig.setOnPreferenceClickListener(this);
importConfig = findPreference("import");
importConfig.setOnPreferenceClickListener(this);
}