How to check if “Radiobutton” is checked?

前端 未结 10 438
萌比男神i
萌比男神i 2020-12-06 06:01

I would like to make a structure with the condition (if-else) RadioButton

I want that when the Radiobutton RB1 is selected, this function is ac

10条回答
  •  北海茫月
    2020-12-06 06:49

    Simple Solution

    radioSection.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(RadioGroup group1, int checkedId1) {
                  switch (checkedId1) {
                      case R.id.rbSr://radiobuttonID
                          //do what you want
                          break;
                      case R.id.rbJr://radiobuttonID
                          //do what you want
                          break;
                  }
              }
          });
    

提交回复
热议问题