为了账号安全,请及时绑定邮箱和手机立即绑定

如何检测哪个radiogroup按钮被选中了呢?

如何检测哪个radiogroup按钮被选中了呢?

qq_笑_17 2019-03-13 18:15:18
在radiogroup中有三个radiobuttons,我使用Java如何实现不同按钮被选中会发生不同的动作?下面是关于radiogroup和radiobutton的代码:final RadioGroup size = (RadioGroup)findViewById(R.id.RGSize);         final RadioButton small = (RadioButton)findViewById(R.id.RBS);         final RadioButton medium = (RadioButton)findViewById(R.id.RBM);         final RadioButton large = (RadioButton)findViewById(R.id.RBL); if (size.getCheckedRadioButtonId().equals(small){ } else{ }但是equals不是正确的语法。如何用Java实现按钮被选中后发生动作的功能?
查看完整描述

3 回答

?
婷婷同学_

TA贡献1844条经验 获得超8个赞

使用这段代码可以实现:

 if (size.getCheckedRadioButtonId() == small.getId()){
     ....
    }
    else if(size.getCheckedRadioButtonId() == medium.getId()){
     ....
    }


查看完整回答
反对 回复 2019-04-26
?
拉丁的传说

TA贡献1789条经验 获得超8个赞

getCheckedRadioButtonId


查看完整回答
反对 回复 2019-04-26
  • 3 回答
  • 0 关注
  • 2240 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号