本文整理汇总了Java中android.preference.Preference.setOnPreferenceChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setOnPreferenceChangeListener方法的具体用法?Java Preference.setOnPreferenceChangeListener怎么用?Java Preference.setOnPreferenceChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setOnPreferenceChangeListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
if (preference instanceof SwitchPreference) {
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getBoolean(preference.getKey(), false));
} else {
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
}
示例2: PrefListener
import android.preference.Preference; //导入方法依赖的package包/类
public PrefListener(String key) {
super();
Preference preference = findPreference(key);
format = preference.getSummary().toString();
if (EditTextPreference.class.isInstance(preference)) {
// EditText
EditTextPreference etp = (EditTextPreference) preference;
onPreferenceChange(preference, etp.getText());
} else if (ListPreference.class.isInstance(preference)) {
// List 切换推送通道 注册及关闭Miui和华为推送
ListPreference lp = (ListPreference) preference;
onPreferenceChange(preference, lp.getEntry());
} else {
Log.e("GcmForMojoSetting", "不支持的Preference类型");
}
preference.setOnPreferenceChangeListener(this);
}
示例3: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_theme);
Preference preferencePrimaryColor = findPreference(KEY_PRIMARY_COLOR);
preferencePrimaryColor.setOnPreferenceChangeListener(this);
preferencePrimaryColor.setOnPreferenceClickListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
Preference preferenceThemeStyle = findPreference(KEY_THEME_STYLE);
preferenceThemeStyle.setOnPreferenceChangeListener(this);
preferenceThemeStyle.setOnPreferenceClickListener(this);
}
示例4: 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 #onPreferenceChangeListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
final String key = preference.getKey();
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(onPreferenceChangeListener);
// Trigger the listener immediately with the preference's
// current value.
switch (key) {
case PreferencesUtils.PREFERENCES_FILTER_LOCATION_EVENTS:
onPreferenceChangeListener.onPreferenceChange(preference,
Prefs.with(preference.getContext()).read(key));
break;
case PreferencesUtils.PREFERENCES_SELECTED_COUNTRY:
onPreferenceChangeListener.onPreferenceChange(preference,
Prefs.with(preference.getContext()).read(key, LocaleUtils.getDeviceLocale(preference.getContext())));
break;
}
}
示例5: 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.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
示例6: 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.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
示例7: bindPreferenceSummaryToValue
import android.preference.Preference; //导入方法依赖的package包/类
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.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
示例8: 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 #preferenceSummaryBinder
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(preferenceSummaryBinder);
// Trigger the listener immediately with the preference's current value.
preferenceSummaryBinder.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
示例9: bind
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 #listener
*/
private static void bind(@NonNull final Preference preference)
{
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(SettingsActivity.listener);
// Trigger the listener immediately with the preference's current value.
SettingsActivity.listener.onPreferenceChange(preference, PreferenceManager.getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), ""));
}
示例10: bindPreferenceSummaryToValue
import android.preference.Preference; //导入方法依赖的package包/类
private static void bindPreferenceSummaryToValue(Preference preference) {
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
示例11: bindPreferenceSummaryToValueString
import android.preference.Preference; //导入方法依赖的package包/类
private void bindPreferenceSummaryToValueString(Context context, Preference preference) {
preference.setOnPreferenceChangeListener(sBindPreferenceToValueListener);
sBindPreferenceToValueListener.onPreferenceChange(preference, PreferenceManager.getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), ""));
}
示例12: bindPreferenceSummaryToValue
import android.preference.Preference; //导入方法依赖的package包/类
private void bindPreferenceSummaryToValue(Preference preference){
preference.setOnPreferenceChangeListener(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(preference.getContext());
String preferenceString = preferences.getString(preference.getKey(), "");
onPreferenceChange(preference, preferenceString);
}
示例13: bindPreferenceSummaryToValue
import android.preference.Preference; //导入方法依赖的package包/类
private void bindPreferenceSummaryToValue(Preference preference) {
preference.setOnPreferenceChangeListener(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(preference.getContext());
String preferenceString = preferences.getString(preference.getKey(), "");
onPreferenceChange(preference, preferenceString);
}