/**
* radioButton的点击监听
*
* */
mRg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
for (int i = 0; i < group.getChildCount(); i++) {
if (i == checkedId) {
RadioButton button = (RadioButton) group.getChildAt(i);
//将图片设置给radioButton的下面
button.setCompoundDrawablesWithIntrinsicBounds(null,
null, null,
getResources().getDrawable(R.drawable.pic2));
//设置button的字为绿色
button.setTextColor(Color.GREEN);
mVp.setCurrentItem(i);
} else {
RadioButton button = (RadioButton) group.getChildAt(i);
button.setCompoundDrawablesWithIntrinsicBounds(null,
null, null,
getResources().getDrawable(R.drawable.pic1));
button.setTextColor(Color.BLACK);
}
}
}
});
* radioButton的点击监听
*
* */
mRg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
for (int i = 0; i < group.getChildCount(); i++) {
if (i == checkedId) {
RadioButton button = (RadioButton) group.getChildAt(i);
//将图片设置给radioButton的下面
button.setCompoundDrawablesWithIntrinsicBounds(null,
null, null,
getResources().getDrawable(R.drawable.pic2));
//设置button的字为绿色
button.setTextColor(Color.GREEN);
mVp.setCurrentItem(i);
} else {
RadioButton button = (RadioButton) group.getChildAt(i);
button.setCompoundDrawablesWithIntrinsicBounds(null,
null, null,
getResources().getDrawable(R.drawable.pic1));
button.setTextColor(Color.BLACK);
}
}
}
});