我有一个CheckBoxPreference和一个setOnPreferenceClickListener
mCheckBoxPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
mCheckBoxPreference.setChecked(!mCheckBoxPreference.isChecked());
Toast.makeText(getActivity(), "Some text", Toast.LENGTH_SHORT).show();
return false;// if return true, is always set checked flase
}
});
但是当点击复选框时,它始终设置为true。我不知道为什么!