Reputation: 21627
I need to set a custom color to a list item based on a property of item from adapter and I can not use a selector (condition for item to have custom color is an item property, not a selected or focused state). In getView method I set
view.setBackgroundColor(R.color.blue)
but this does not works because it doesn't matter what color I set for background, the result is the same. I tried to set background color to the layout but the result is the same. Can you please give me a clue? Thanks
Upvotes: 1
Views: 2103
Reputation: 1091
Try:
view.setBackgroundColor(getResources().getColor(R.color.blue));
Upvotes: 0
Reputation: 29121
use ,
view.setBackgroundResource(R.color.blue)
it will work.
Upvotes: 4