I have a PreferenceActivity
containing a number of CheckBoxPreference
and I want to make sure that at least one of them is selected, any suggestion on how to do it?
Thanks
Asked
Active
Viewed 915 times
0

Andrea Vacondio
- 888
- 9
- 19
2 Answers
1
I ended up registering the same instance of Preference.OnPreferenceChangeListener
on all my CheckBoxPreference
. The listener keeps a set with my CheckBoxPreference
and reacts when the user unchecks one, returning false if it's the only one checked.

Andrea Vacondio
- 888
- 9
- 19
0
Cant you use .setChecked(true) on the checkbox control
i.e.
// get the control final CheckBox chkRemember = (CheckBox) findViewById(R.id.checkbox);
// pull th evalue from your preferences strChecked = rwPref.readWriteUserSetting(DevDroidSLX.this, "Read", "CheckboxValueA" , "" );
if ( strChecked.equalsIgnoreCase("True"))
{
chkRemember.setChecked(true);
}
else
{
chkRemember.setChecked(false);
}

Ronan
- 1
-
Simplified as chkRemember.setChecked(strChecked.equalsIgnoreCase("True")); – Greg Jul 27 '11 at 16:05