通过代码setTextColor时、如果color是一个资源文件 会set失败 没有效果
遇到这样的情况有两种解决办法、亲测过、两种都是有效的
一、注解方式
通过在方法上面添加注解解决问题
代码如下
@SuppressLint("ResourceAsColor") 无效
二、CONTEXT方式
通过Context 获取getColorStateList 来解决问题
代码如下
ColorStateList color = getContext() .getResources() .getColorStateList(R.color.reservation_text); textView.setTextColor(color);