RadioGroup:放在RadioGroup中的RadionButton只能选择一个。

用处:在性别组里,只能选择一个

Android 常用控件-RadioGroup

上图中第一组男性与女性放在RadioGroup中,下面的男性与女性没有放在RadioGroup中,上面的只能单选,下面的可以多选。中间的是CheckBox不是单选按钮RadioGroup,也是可以多选的。

 

特别要注意的是

CheckBox设置

setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener())

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
  
 {
    if(isChecked)
    {
     Toast.makeText(RadioGroupActivity.this, addrcb2.getText()+"lucked", Toast.LENGTH_SHORT).show();
    }
    else
    {
     Toast.makeText(RadioGroupActivity.this, addrcb2.getText()+"unlucked", Toast.LENGTH_SHORT).show();
    }
   }

 

 

相关文章:

  • 2022-01-27
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-05-04
猜你喜欢
  • 2022-12-23
  • 2021-05-29
  • 2021-04-30
  • 2022-12-23
相关资源
相似解决方案