我在一個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