radio_Group设置一个点击事件
radio_Group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (i) {
case R.id.rb_baidu:
rb_Baidu.setBackgroundDrawable(getResources().getDrawable(R.drawable.jia));
rb_Lunbo.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
rb_Nanian.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
break;//嗯嗯 有两种办法,一种是写代码,有点臃肿,但是理解起来简单 还有一种使用xml比较简单
case R.id.rb_lunbo:
rb_Baidu.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
rb_Lunbo.setBackgroundDrawable(getResources().getDrawable(R.drawable.jia));
rb_Nanian.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
break;
case R.id.rb_nanian:
rb_Baidu.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
rb_Lunbo.setBackgroundDrawable(getResources().getDrawable(R.drawable.li));
rb_Nanian.setBackgroundDrawable(getResources().getDrawable(R.drawable.jia));;
break;
}
}
});