当前位置: 首页>>代码示例>>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;未经允许,请勿转载。