我在一个radiogroup中有三个单选按钮。我如何告诉Java根据所选按钮做不同的事情?我有组和所有的按钮声明:如何检查选择了哪个radiogroup按钮?
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{
}
但等于不正确的语法...我怎么能要求它的Java按钮被选中?
请看看http://www.thetekblog.com/2010/07/android-radiobutton-in-radiogroup -例/ – 2012-04-04 00:47:09