I have an activity that extends PreferenceActivity. I have in settings.xml 3 checkboxpreferences. If I uncheck the first checkbox, the other 2 to uncheck. What is the code for that?
Asked
Active
Viewed 37 times
1 Answers
0
I think you want to use checkbox.toggle()
First make a onClickListener:
Checkbox chk = (CheckBox)findViewById(R.id.checkBox1);
chk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
}
}
);
Then change the other checkboxes:
CheckBox chk1, chk2;
chk1 = (CheckBox)findViewById(R.id.checkBox2);
chk2 = (CheckBox)findViewById(R.id.checkBox3);
and:
if(chk1.isChecked()){
chk1.toggle();
}
if(chk2.isChecked()){
chk2.toggle();
}

moffeltje
- 4,521
- 4
- 33
- 57