本文整理汇总了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);
}
示例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));
}
示例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;
}
示例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;
}