android/View/RadioButton

Last-modified: 2012-10-10 (水) 00:02:24

RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radiogroup);

//グループのどのボタンがチェックされているか調べたい場合の例

//getCheckedRadioButtonId()メソッドの復帰値はR.javaで定義されているIDとなる

if(radioGroup.getCheckedRadioButtonId() == R.id.radioButton1){

}

//選択されているボタンのラベルを取得したい場合

RadioButton radioButton = (RadioButton)findViewById(radioGroup.getCheckedRadioButtonId());

String buttonLabel = radioButton.getText().toString();