TextView动态设置字体颜色selector不起作用?

来源:互联网 发布:南京纬创软件 编辑:程序博客网 时间:2024/05/22 13:03

在代码中动态设置了TextView的颜色选择器

holder.bt_buy.setTextColor(mcontext.getResources().getColor(R.color.selector_text_orange_white));

然而这个并没有什么效果,

应该这么写:

holder.bt_buy.setTextColor(mcontext.getResources().getColorStateList(R.color.selector_text_orange_white));
当然在布局中还是可以直接使用:

android:textColor="@color/selector_text_theme_white"

原创粉丝点击