本文整理汇总了Java中android.support.v7.preference.ListPreference.setEntryValues方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.setEntryValues方法的具体用法?Java ListPreference.setEntryValues怎么用?Java ListPreference.setEntryValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.ListPreference
的用法示例。
在下文中一共展示了ListPreference.setEntryValues方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAvailableFragments
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void updateAvailableFragments(List<? extends MainFragmentPresenter> presenters) {
ListPreference list = (ListPreference) getPreferenceScreen().findPreference("defaultFragment");
CharSequence[] labels = StreamSupport.stream(presenters)
.map(MainFragmentPresenter::getTitle)
.map(this::getString)
.toArray(CharSequence[]::new);
CharSequence[] values = StreamSupport.stream(presenters)
.map(MainFragmentPresenter::getTitle)
.map(String::valueOf)
.toArray(CharSequence[]::new);
list.setEntries(labels);
list.setEntryValues(values);
}
示例2: configureHomePage
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void configureHomePage() {
String[] namesArray = getResources().getStringArray(R.array.query_filters_ids_names);
String[] titlesArray = getResources().getStringArray(R.array.query_filters_ids_titles);
String[] authArray = getResources().getStringArray(R.array.query_filters_auth);
boolean authenticated = mAccount.hasAuthenticatedAccessMode();
List<String> names = new ArrayList<>();
List<String> titles = new ArrayList<>();
int count = authArray.length;
for (int i = 0; i < count ; i++) {
if ((authenticated || !Boolean.valueOf(authArray[i]))
&& isEntrySupported(namesArray[i])) {
names.add(namesArray[i]);
titles.add(titlesArray[i]);
}
}
List<CustomFilter> filters = Preferences.getAccountCustomFilters(getContext(), mAccount);
if (filters != null) {
for (CustomFilter filter : filters) {
names.add(Constants.CUSTOM_FILTER_PREFIX + filter.mId);
titles.add(filter.mName);
}
}
// Add the entries y values
mHomePage = (ListPreference) findPreference(PREF_ACCOUNT_HOME_PAGE);
mHomePage.setEntries(titles.toArray(new String[titles.size()]));
mHomePage.setEntryValues(names.toArray(new String[names.size()]));
mHomePage.setDefaultValue(Preferences.getDefaultHomePageForAccount(mAccount));
String value = Preferences.getAccountHomePage(getContext(), mAccount);
if (!names.contains(value)) {
value = Preferences.getDefaultHomePageForAccount(mAccount);
}
mHomePage.setValue(value);
updateHomePageSummary(mHomePage.getValue());
mHomePage.setOnPreferenceChangeListener(this);
}
示例3: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.preferences);
Preference openSchdSetup = findPreference(PrefUtils.PREF_OPEN_SCHEDULE_SETUP);
openSchdSetup.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(getActivity(), ScheduleSetupActivity.class);
intent.putExtra(ScheduleSetupActivity.EXTRA_OPTIONAL, true);
startActivity(intent);
return true;
});
ListPreference modes = (ListPreference) findPreference(PrefUtils.PREF_MODE);
modes.setEntryValues(new String[]{"0", "1", "2"});
}
示例4: onCreate
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make sure default values are applied. In a real app, you would
// want this in a shared function that is used to retrieve the
// SharedPreferences wherever they are needed.
PreferenceManager.setDefaultValues(getActivity(),
R.xml.preference_app, false);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preference_app);
if (BuildConfig.FOSS_ONLY) {
// disable tracking if GA is not used
CheckBoxPreference trackingErrors = (CheckBoxPreference) findPreference(PreferenceWrapper.PREF_TRACKING_ERRORS);
trackingErrors.setEnabled(false);
trackingErrors.setChecked(false);
}
ListPreference mapFiles = (ListPreference) findPreference(PreferenceWrapper.PREF_MAP_FILE);
if (mapFiles != null) {
ArrayList<String> entries = new ArrayList<>();
ArrayList<String> entryValues = new ArrayList<>();
CollectMapFiles(entries, entryValues);
mapFiles.setEntries(entries.toArray(new CharSequence[entries.size()]));
mapFiles.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
int index = Math
.max(mapFiles.findIndexOfValue(getPreferenceManager().getSharedPreferences().getString(
mapFiles.getKey(), "")), 0);
mapFiles.setValueIndex(index);
}
}
示例5: populateListPreference
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private <T extends Enum> void populateListPreference(
ListPreference pref, T[] enumValues, Map<T, String> displayValues) {
String[] entryValues = new String[enumValues.length];
String[] entryDisplay = new String[enumValues.length];
for (int i = 0; i < entryValues.length; i++) {
entryValues[i] = enumValues[i].toString();
entryDisplay[i] = displayValues.get(enumValues[i]);
}
pref.setEntryValues(entryValues);
pref.setEntries(entryDisplay);
}
示例6: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@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);
}
示例7: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s)
{
super.onCreatePreferences(bundle, s);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
getContext());
// Get our screen which is created in Skin SettingsFragment
PreferenceScreen screen = getPreferenceScreen();
// Get profile preference
PreferenceCategory category = (PreferenceCategory) screen.findPreference(KEY_PROFILE);
// If category exists, we should add mole mapper specific things. If not, that means we
// are not consented so we have no data to set.
if(category != null)
{
// Occupation Preference
Preference checkBoxPref = new Preference(screen.getContext());
checkBoxPref.setKey(KEY_PROFILE_PROFESSION);
checkBoxPref.setTitle(R.string.profession);
checkBoxPref.setSummary(R.string.profession_unknown); // Set to prevent a "jump" when first entering the screen
category.addPreference(checkBoxPref);
}
// Create the app category to place out two rpefs
PreferenceCategory appCategory = new PreferenceCategory(screen.getContext());
appCategory.setKey(KEY_APP);
appCategory.setTitle(R.string.settings_app);
appCategory.setOrder(1);
screen.addPreference(appCategory);
// Generate values for the mole naming convention pref
MoleNameHelper.Gender[] values = MoleNameHelper.Gender.values();
String[] entries = new String[values.length];
String[] entryValues = new String[values.length];
for(int i = 0; i < values.length; i++)
{
MoleNameHelper.Gender gender = values[i];
entries[i] = getString(gender.getNameResourceId());
entryValues[i] = Integer.toString(i);
}
// Create ListPreference and add to "App" category
String defaultNamingConvention = Integer.toString(MoleNameHelper.Gender.RANDOM.ordinal());
ListPreference namingConventionPref = new ListPreference(screen.getContext());
namingConventionPref.setTitle(R.string.settings_app_mole_name_scheme);
namingConventionPref.setKey(KEY_APP_MOLE_NAMING);
namingConventionPref.setDefaultValue(defaultNamingConvention);
namingConventionPref.setEntries(entries);
namingConventionPref.setEntryValues(entryValues);
namingConventionPref.setDialogTitle(R.string.settings_app_mole_name_scheme);
String currentNamingConvInt = sharedPreferences.getString(KEY_APP_MOLE_NAMING,
defaultNamingConvention);
int currentNamingOrdinal = Integer.parseInt(currentNamingConvInt);
namingConventionPref.setSummary(values[currentNamingOrdinal].getNameResourceId());
appCategory.addPreference(namingConventionPref);
}
示例8: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.password_constraint_preferences);
mMinLength = (DpcPreferenceBase) findPreference(Keys.MIN_LENGTH);
mMinLetters = (DpcPreferenceBase) findPreference(Keys.MIN_LETTERS);
mMinNumeric = (DpcPreferenceBase) findPreference(Keys.MIN_NUMERIC);
mMinLower = (DpcPreferenceBase) findPreference(Keys.MIN_LOWERCASE);
mMinUpper = (DpcPreferenceBase) findPreference(Keys.MIN_UPPERCASE);
mMinSymbols = (DpcPreferenceBase) findPreference(Keys.MIN_SYMBOLS);
mMinNonLetter = (DpcPreferenceBase) findPreference(Keys.MIN_NONLETTER);
// Populate password quality settings - messy because the only API for this requires two
// separate String[]s.
List<CharSequence> entries = new ArrayList<>();
List<CharSequence> values = new ArrayList<>();
for (Map.Entry<Integer, Integer> entry : PASSWORD_QUALITIES.entrySet()) {
values.add(Integer.toString(entry.getKey()));
entries.add(getString(entry.getValue()));
}
ListPreference quality = (ListPreference) findPreference(Keys.QUALITY);
quality.setEntries(entries.toArray(new CharSequence[0]));
quality.setEntryValues(values.toArray(new CharSequence[0]));
// Expiration times.
setup(Keys.EXPIRATION_TIME, null);
setup(Keys.HISTORY_LENGTH, getDpm().getPasswordHistoryLength(getAdmin()));
// Minimum quality requirement.
setup(Keys.QUALITY, PASSWORD_QUALITIES.floorKey(getDpm().getPasswordQuality(getAdmin())));
// Minimum length requirements.
setup(Keys.MIN_LENGTH, getDpm().getPasswordMinimumLength(getAdmin()));
setup(Keys.MIN_LETTERS, getDpm().getPasswordMinimumLetters(getAdmin()));
setup(Keys.MIN_NUMERIC, getDpm().getPasswordMinimumNumeric(getAdmin()));
setup(Keys.MIN_LOWERCASE, getDpm().getPasswordMinimumLowerCase(getAdmin()));
setup(Keys.MIN_UPPERCASE, getDpm().getPasswordMinimumUpperCase(getAdmin()));
setup(Keys.MIN_SYMBOLS, getDpm().getPasswordMinimumSymbols(getAdmin()));
setup(Keys.MIN_NONLETTER, getDpm().getPasswordMinimumNonLetter(getAdmin()));
setPreferencesConstraint();
}
示例9: setDetails
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void setDetails(AccountConfig config, String[] tlsMethods) {
for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) {
final Preference current = tlsCategory.getPreference(i);
final ConfigKey key = ConfigKey.fromString(current.getKey());
if (current instanceof TwoStatePreference) {
((TwoStatePreference) current).setChecked(config.getBool(key));
} else {
if (key == ConfigKey.TLS_CA_LIST_FILE) {
File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE));
current.setSummary(crt.getName());
setFeedbackIcon(current);
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) {
current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName());
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_CERTIFICATE_FILE) {
File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE));
current.setSummary(pem.getName());
setFeedbackIcon(current);
checkForRSAKey();
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_METHOD) {
ListPreference listPref = (ListPreference) current;
String curVal = config.get(key);
listPref.setEntries(tlsMethods);
listPref.setEntryValues(tlsMethods);
listPref.setValue(curVal);
current.setSummary(curVal);
} else if (current instanceof EditTextPreference) {
String val = config.get(key);
((EditTextPreference) current).setText(val);
current.setSummary(val);
} else {
current.setSummary(config.get(key));
}
}
current.setOnPreferenceChangeListener(tlsListener);
}
}