android java代码中设置radiobutton选中与为选中颜色

tab_rb_b.setTextColor(MainActivity.this.getResources().getColor(R.drawable.main_text_color));
其中R.drawable.main_text_color是自己写好的 颜色改变的xml


<!-- not selected -->


但是设好之后 颜色并没有随选中而改变,只是一直都是为选中状态的颜色。
哪位大神知道是怎么回事吗?

radioButton.setTextColor(getResources().getColorStateList(R.color.selector_filter_text_color));

换成getColorStateList

在Xml中写好selector 在selector中指定好选中的颜色和未选中的颜色。
然后在radioButton的Xml文件中设置background属性为R.Drawable.selector文件名,
这样就OK了

同求呀,哥们解决了的话报一下,谢了。。。

button1.setTextColor(this.getResources().getColorStateList(R.drawable.color_radiobutton));这么做是对的,可以显示选中和未选中的颜色,