當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。