我有一个 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。我不知道为什么!