开发者

Android:About listview's item color

开发者 https://www.devze.com 2023-03-17 02:50 出处:网络
I add a listview and add some textview into it. In the listview\'s OnItemCLickListener I wanna change the textColor , then problems come:When I change the text color by setTextColor(Color.BLACK) ,the

I add a listview and add some textview into it. In the listview's OnItemCLickListener I wanna change the textColor , then problems come:When I change the text color by setTextColor(Color.BLACK) ,the item will change to black开发者_运维问答;But when I change the color by setTextColor(R.color.mycolor) , all the items' color will change ! I cannot understand why? Is there any way to solve this problem? Thanks first!


setTextColor(int) expects a "color integer", not a "resource integer". Try doing this instead:

    setTextColor(getResources().getColor(R.color.mycolor));

See docs.


Check your code and make sure you're calling setTextColor on just one specific instance in your list. That's the best help I can give you without having some code to go on.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号