I've implemented SwitchPreference in PreferenceFragment and it works like a champ. But when I implement setOnPreferenceChangeListener on it its state does not change on the click event. Here is my implementation. Please have a look.
track_location = (CheckBoxPreference) findPreference("location_tracking");
track_location.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return false;
}
});
if I remove the listener line, it works perfectly fine.
您必须在onPreferenceChange内部返回true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.