本文整理汇总了Java中android.preference.ListPreference.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.getValue方法的具体用法?Java ListPreference.getValue怎么用?Java ListPreference.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.ListPreference
的用法示例。
在下文中一共展示了ListPreference.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePref
import android.preference.ListPreference; //导入方法依赖的package包/类
/**
* Update a preference
* @param key - which preference
*/
private void updatePref(String key){
ListPreference preference = (ListPreference) findPreference(key);
CharSequence entry = preference.getEntry();
String value = preference.getValue();
preference.setSummary(entry);
SharedPreferences.Editor editor = mPreferences.edit();
// Fucking strangely, a string cannot be parsed to an integer
editor.putString(key, value);
editor.apply();
}
示例2: prepareListPreference
import android.preference.ListPreference; //导入方法依赖的package包/类
private void prepareListPreference(final ListPreference listPreference)
{
if (listPreference == null)
{
return;
}
if (listPreference.getValue() == null)
{
// to ensure we don't get a null value
// set first value by default
listPreference.setValueIndex(0);
}
if (listPreference.getEntry() != null)
{
listPreference.setSummary(listPreference.getEntry().toString());
}
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
listPreference.setValue(newValue.toString());
preference.setSummary(listPreference.getEntry().toString());
return true;
}
});
}
示例3: onSharedPreferenceChanged
import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
TelemetryWrapper.settingsEvent(key, String.valueOf(sharedPreferences.getAll().get(key)));
if (!localeUpdated && key.equals(getString(R.string.pref_key_locale))) {
// Updating the locale leads to onSharedPreferenceChanged being triggered again in some
// cases. To avoid an infinite loop we won't update the preference a second time. This
// fragment gets replaced at the end of this method anyways.
localeUpdated = true;
final ListPreference languagePreference = (ListPreference) findPreference(getString(R.string.pref_key_locale));
final String value = languagePreference.getValue();
final LocaleManager localeManager = LocaleManager.getInstance();
final Locale locale;
if (TextUtils.isEmpty(value)) {
localeManager.resetToSystemLocale(getActivity());
locale = localeManager.getCurrentLocale(getActivity());
} else {
locale = Locales.parseLocaleCode(value);
localeManager.setSelectedLocale(getActivity(), value);
}
localeManager.updateConfiguration(getActivity(), locale);
// Manually notify SettingsActivity of locale changes (in most other cases activities
// will detect changes in onActivityResult(), but that doesn't apply to SettingsActivity).
getActivity().onConfigurationChanged(getActivity().getResources().getConfiguration());
// And ensure that the calling LocaleAware*Activity knows that the locale changed:
getActivity().setResult(SettingsActivity.ACTIVITY_RESULT_LOCALE_CHANGED);
// The easiest way to ensure we update the language is by replacing the entire fragment:
getFragmentManager().beginTransaction()
.replace(R.id.container, SettingsFragment.newInstance(null, SettingsScreen.MAIN))
.commit();
}
}
示例4: onCreate
import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_advanced);
final Resources res = getResources();
final Context context = getActivity();
// When we are called from the Settings application but we are not already running, some
// singleton and utility classes may not have been initialized. We have to call
// initialization method of these classes here. See {@link LatinIME#onCreate()}.
AudioAndHapticFeedbackManager.init(context);
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
if (!Settings.isInternal(prefs)) {
removePreference(Settings.SCREEN_DEBUG);
}
if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) {
removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
}
// TODO: consolidate key preview dismiss delay with the key preview animation parameters.
if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
} else {
// TODO: Cleanup this setup.
final ListPreference keyPreviewPopupDismissDelay =
(ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout));
keyPreviewPopupDismissDelay.setEntries(new String[] {
res.getString(R.string.key_preview_popup_dismiss_no_delay),
res.getString(R.string.key_preview_popup_dismiss_default_delay),
});
keyPreviewPopupDismissDelay.setEntryValues(new String[] {
"0",
popupDismissDelayDefaultValue
});
if (null == keyPreviewPopupDismissDelay.getValue()) {
keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
}
keyPreviewPopupDismissDelay.setEnabled(
Settings.readKeyPreviewPopupEnabled(prefs, res));
}
setupKeypressVibrationDurationSettings();
setupKeypressSoundVolumeSettings();
setupKeyLongpressTimeoutSettings();
setupKeyboardHeightSettings();
refreshEnablingsOfKeypressSoundAndVibrationSettings();
setupKeyboardColorSettings();
}
示例5: onCreate
import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_advanced);
final Resources res = getResources();
final Context context = getActivity();
// When we are called from the Settings application but we are not already running, some
// singleton and utility classes may not have been initialized. We have to call
// initialization method of these classes here. See {@link LatinIME#onCreate()}.
AudioAndHapticFeedbackManager.init(context);
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
if (!Settings.isInternal(prefs)) {
removePreference(Settings.SCREEN_DEBUG);
}
if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) {
removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
}
// TODO: consolidate key preview dismiss delay with the key preview animation parameters.
if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
} else {
// TODO: Cleanup this setup.
final ListPreference keyPreviewPopupDismissDelay =
(ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout));
keyPreviewPopupDismissDelay.setEntries(new String[] {
res.getString(R.string.key_preview_popup_dismiss_no_delay),
res.getString(R.string.key_preview_popup_dismiss_default_delay),
});
keyPreviewPopupDismissDelay.setEntryValues(new String[] {
"0",
popupDismissDelayDefaultValue
});
if (null == keyPreviewPopupDismissDelay.getValue()) {
keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
}
keyPreviewPopupDismissDelay.setEnabled(
Settings.readKeyPreviewPopupEnabled(prefs, res));
}
setupKeypressVibrationDurationSettings();
setupKeypressSoundVolumeSettings();
setupKeyLongpressTimeoutSettings();
refreshEnablingsOfKeypressSoundAndVibrationSettings();
}