How to do something when a checkbox change state?

后端 未结 3 784
抹茶落季
抹茶落季 2020-12-07 01:24

This is my code:

    

        
3条回答
  •  佛祖请我去吃肉
    2020-12-07 01:29

    I believe a RadioButton would be more suitable for your aims.

    
        
        
        
    
    

    Then in your code:

    public void onRadioButtonClick(View v) {
        RadioButton button = (RadioButton) v;
        // DO YOUR THING HERE DEPENDING ON WHICH RADIOBUTTON IS PICKED
    }
    

    In this case, you won't have to deal with disabling other options. The user will have only one option to pick by default.

提交回复
热议问题