0

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

Andrea Vacondio
  • 888
  • 9
  • 19

2 Answers2

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