Colour resource ID returning wrong value

I am trying to set the text colour programatically from a colour resource during onCreate and am getting some wierd results. I have a colour resource defined in res\colors.xml: #C0FFFFFF my activity then uses the following code to retrieve the colour: int WheelColour = getResources().getColor(R.color.wheelFill); Finally I assign it to a Paint: mBackgroundPaint.setColor(WheelColour); When I run my application the colour does not get set an I get a log message from the getColor line claiming that "Color value 'List' must start with #". 'List' is the value of one of my string resources so clearly something is getting messed up there. If I bypass the resource and use: int WheelColour = Color.argb(0xC0, 0xFF, 0xFF, 0xFF); Everything works correctly so it has to be the getColor call but I can't see what's wrong with it. (I have tried explicitly using a context which made no difference). Has anybody else come across this or sucessfully managed to set paint colours from colour resources?
maybe your R.java got messed up and isn't linking to the correct resource. clean the project and refresh

以上就是Colour resource ID returning wrong value的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏