I need to control a CheckBoxPreference
manually; I have to check a condition in my own data to determine if the preference can be set or not.
How can I do it? My current code is as follows, but it doesn't seem to work.
CheckBoxPreference buyPref = (CheckBoxPreference) findPreference("pref_billing_buy");
buyPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
if (something) {
return true; // checkbox should be checked
} else {
return false; // checkbox should be unchecked
}
Should I always return false
and then use
buyPref.setChecked(true);