其实是代码中设置错误
setTextColor(int color)误导输入了颜色的资源,因为R.color.alert_dialog_button_disable_color也是个int值
**
* Sets the text color for all the states (normal, selected,
* focused) to be this color.
*
* @param color A color value in the form 0xAARRGGBB.
* Do not pass a resource ID. To get a color value from a resource ID, call
* {@link android.support.v4.content.ContextCompat#getColor(Context, int) getColor}.
*
* @see #setTextColor(ColorStateList)
* @see #getTextColors()
*
* @attr ref android.R.styleable#TextView_textColor
*
@android.view.RemotableViewMethod
public void setTextColor(@ColorInt int color) {
mTextColor = ColorStateList.valueOf(color);
updateTextColors();
}
可以从上面的源码看到,颜色是值得一个0xAARRGGBB的int值,而R.color获取到的是一个颜色的id值
View.setTextColor(填充颜色);
ins.setTextColor(R.color.alert_dialog_button_disable_color); 错误的调用方法
ins.setTextColor(getResources().getColor(R.color.alert_dialog_button_disable_color));正确的调用方法**粗体**
评论区