SettingsActivity.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:Damsel-In-Distress 作者:
/**
 * 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.
 */
private static void bindPreference(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreference);

    // Trigger the listener immediately with the preference's
    // current value.
    if (preference instanceof SwitchPreference) {
        sBindPreference.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getBoolean(preference.getKey(), true));
    } else {
        sBindPreference.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getString(preference.getKey(), ""));
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号