RadioGroup 组与 onCheckedChanged 事件

answer_TextView=(TextView)findViewById(R.id.TextView_Ask_And_Show);
radioGroup=(RadioGroup)findViewById(R.id.RadioGroup);
boy_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Boy);
girl_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Gril);
/*给单RadioGroup添加状态改变监听器*/
radioGroup.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if(boy_RadioButton.isChecked()){
answer_TextView.setText(R.string.iam_Boy);
}else{
answer_TextView.setText(R.string.iamGirl);
}
}
});

posted @ 2013-12-24 14:21  爱编程hao123  阅读(608)  评论(0编辑  收藏  举报