1

I have two checkboxes with yes or no options.I have to select only one option while disabling the clickable option of other checkbox. opp11 and op12 are two checkboxes.The following code seems to work but what if i have around 20 checkbox options.Is there any method to shorten the code like i can pass two options one to set onchanged listner and other to disable the clickable option.

op11.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

        @Override
        public void onCheckedChanged(CompoundButton buttonView,
        boolean isChecked) {
        if(isChecked){
            op12.setChecked(false);
            // Code to display your message.
            }
        }
    });
Hari Sankar
  • 197
  • 2
  • 15
  • 1
    I think you are looking for `Radio Button` – Skynet May 15 '15 at 10:11
  • @Skynet i cant use radio button..only checkbox..part of design – Hari Sankar May 15 '15 at 10:13
  • 1
    It would be tedious, implement a checkChangeListener in your check buttons and manuplate checks there. Else you can create a utility method pass arguments which checkboxes need to be checked and which should be unchecked. – Skynet May 15 '15 at 10:13

0 Answers0