當前位置: 首頁>>代碼示例>>Java>>正文


Java Preference.getSharedPreferences方法代碼示例

本文整理匯總了Java中android.preference.Preference.getSharedPreferences方法的典型用法代碼示例。如果您正苦於以下問題:Java Preference.getSharedPreferences方法的具體用法?Java Preference.getSharedPreferences怎麽用?Java Preference.getSharedPreferences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.Preference的用法示例。


在下文中一共展示了Preference.getSharedPreferences方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindPreferenceSummaryToValue

import android.preference.Preference; //導入方法依賴的package包/類
/**
 * Binds a preference's summary to its value. More specifically, when the
 * preference's value is changed, its summary (line of text below the
 * preference title) is updated to reflect the value. The summary is also
 * immediately updated upon calling this method. The exact display format is
 * dependent on the type of preference.
 *
 * @see #sBindPreferenceSummaryToValueListener
 */
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference's
    // current value.
    SharedPreferences prefs = preference.getSharedPreferences();
    Object value;
    if (preference instanceof MultiSelectListPreference) {
        value = prefs.getStringSet(preference.getKey(), new HashSet<String>());
    } else {
        value = prefs.getString(preference.getKey(), "");
    }
    sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value);
}
 
開發者ID:etsy,項目名稱:divertsy-client,代碼行數:25,代碼來源:SettingsActivity.java

示例2: updateCustomInputStylesSummary

import android.preference.Preference; //導入方法依賴的package包/類
static void updateCustomInputStylesSummary(final Preference pref) {
    // 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()}.
    SubtypeLocaleUtils.init(pref.getContext());

    final Resources res = pref.getContext().getResources();
    final SharedPreferences prefs = pref.getSharedPreferences();
    final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res);
    final InputMethodSubtype[] subtypes =
            AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
    final ArrayList<String> subtypeNames = new ArrayList<>();
    for (final InputMethodSubtype subtype : subtypes) {
        subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype));
    }
    // TODO: A delimiter of custom input styles should be localized.
    pref.setSummary(TextUtils.join(", ", subtypeNames));
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:19,代碼來源:CustomInputStyleSettingsFragment.java

示例3: onPreferenceTreeClick

import android.preference.Preference; //導入方法依賴的package包/類
@Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
  {
SharedPreferences sp = preference.getSharedPreferences();
boolean ON_OFF = sp.getBoolean("auto_send_message", false);
boolean next_screen = sp.getBoolean("next_screen_checkbox_preference", false);
String text = sp.getString("auto_send_message_text", "");
String listtext = sp.getString("auto_send_message_frequency", "");
return true;
  }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:11,代碼來源:GankIoActivity.java

示例4: onPreferenceTreeClick

import android.preference.Preference; //導入方法依賴的package包/類
@Override
   public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
   {
SharedPreferences sp = preference.getSharedPreferences();
boolean ON_OFF = sp.getBoolean("auto_send_message", false);
boolean next_screen = sp.getBoolean("next_screen_checkbox_preference", false);
String text = sp.getString("auto_send_message_text", "");
String listtext = sp.getString("auto_send_message_frequency", "");
return true;
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:11,代碼來源:lua.java


注:本文中的android.preference.Preference.getSharedPreferences方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。