当前位置: 首页>>代码示例>>Java>>正文


Java ListPreference.getValue方法代码示例

本文整理汇总了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();
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:15,代码来源:SettingsActivity.java

示例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;
        }
    });
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:30,代码来源:SettingsActivity.java

示例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();
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:39,代码来源:SettingsFragment.java

示例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();
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:55,代码来源:AdvancedSettingsFragment.java

示例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();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:53,代码来源:AdvancedSettingsFragment.java


注:本文中的android.preference.ListPreference.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。