我已经创建了一个自定义视图,它接受背景颜色resId和阴影颜色resid。但是当我转换资源i以将它们存储在int变量中时。它会给出错误,如 Expected a color resource id (R.color.) but received an RGB integer 下面是我的setter方法 @OverrideshadowColorId) {
this.shadowColor = ContextCompat.getColor(context, shad
R.string.default_color))) ... and so on
但是在标题背景下,我得到了错误消息“需要一个颜色资源id (R.color.),但是接收到一个RGB整数”,并且无法设置从首选项读取的背景色。它给出了日志错误:"android.content.res.Resources$NotFound
TableRow test = (TableRow)findViewById(R.id.tableRow2);这不会将其设置为绿色TableRow test = (TableRow)findViewById(R.id.tableRow2);
test.setBackgroundColor(android.graphics.Color.GREEN