@natsumi 2016-07-18T15:22:13.000000Z 字数 860 阅读 1097

# 监听用户对PreferencesFragment设置的修改

Android

onPreferenceChange：用户修改了preference的值时调用
onSharedPreferenceChanged：设置sharedpreference改变、被添加或被移除时调用

        /**         * Called when a Preference has been changed by the user. This is         * called before the state of the Preference is about to be updated and         * before the state is persisted.         *          * @param preference The changed Preference.         * @param newValue The new value of the Preference.         * @return True to update the state of the Preference with the new value.         */        boolean onPreferenceChange(Preference preference, Object newValue);
        /**         * Called when a shared preference is changed, added, or removed. This         * may be called even if a preference is set to its existing value.         *         * <p>This callback will be run on your main thread.         *         * @param sharedPreferences The {@link SharedPreferences} that received         *            the change.         * @param key The key of the preference that was changed, added, or         *            removed.         */        void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key);

• 私有
• 公开
• 删除