开发者

How to make sure at least one CheckBoxPreference is selected

I have a PreferenceActivity containing a number of CheckBoxPreference开发者_C百科 and I want to make sure that at least one of them is selected, any suggestion on how to do it? Thanks


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.


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);
      }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜