Android官方API文档完整版.chm : http://download.csdn.net/download/haozq2012/7032817
//获得对象
m_RadioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
m_RadioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
//打开界面的时候清楚默认选择项
m_RadioGroup.clearCheck();
m_RadioGroup.clearCheck();
//按钮被触发时的监听事件
m_RadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
String answer = question.getAnswer();
if(m_Radio0.getText().toString().subSequence(0, 1).equals(answer)){
//设置被选中
m_Radio0.setChecked(true);
str="恭喜您答对了!";
}else{
str="您太任性了!答错了哦!";
}
// 吧选择的答案赋值给文本对象m_TextViewanswer
m_TextViewanswer.setText("正确答案:"+answer+">>>>"+str);
}
} );
m_RadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
String answer = question.getAnswer();
if(m_Radio0.getText().toString().subSequence(0, 1).equals(answer)){
//设置被选中
m_Radio0.setChecked(true);
str="恭喜您答对了!";
}else{
str="您太任性了!答错了哦!";
}
// 吧选择的答案赋值给文本对象m_TextViewanswer
m_TextViewanswer.setText("正确答案:"+answer+">>>>"+str);
}
} );