当前位置: 首页>>代码示例>>Java>>正文


Java Preference.setOnPreferenceChangeListener方法代码示例

本文整理汇总了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(), ""));
    }

}
 
开发者ID:ray0711,项目名称:homeDash,代码行数:27,代码来源:SettingsActivity.java

示例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);
}
 
开发者ID:heipidage,项目名称:GcmForMojo,代码行数:19,代码来源:FragmentPreferences.java

示例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);

}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:17,代码来源:ThemePreferenceFragment.java

示例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;
    }

}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:29,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:21,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:comp500,项目名称:SSLSocks,代码行数:21,代码来源:AdvancedSettingsActivity.java

示例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(), ""));
}
 
开发者ID:SEALiu,项目名称:Calendouer,代码行数:12,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:19,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:1313ou,项目名称:TreebolicPlugins,代码行数:16,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:9,代码来源:SettingsActivity.java

示例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(), ""));
}
 
开发者ID:KrongKrongPadakPadak,项目名称:mvo,代码行数:5,代码来源:SettingsFragment.java

示例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);
}
 
开发者ID:ECFK75C8,项目名称:Lagos-Developers-App,代码行数:7,代码来源:Settings.java

示例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);
}
 
开发者ID:raghu619,项目名称:andriodapp,代码行数:7,代码来源:SettingsActivity.java


注:本文中的android.preference.Preference.setOnPreferenceChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。