Reputation: 3
I have a list view in which I am loading my own layout. I am changing the color of the custom view but its not refleting.
How to do this?
Upvotes: 0
Views: 264
Reputation: 3204
Hello If you want to use any two colors then you can use below code into your customAdapter.
private int[] colors = new int[] { Color.LTGRAY, Color.WHITE };
And in getView() write
int colorPos = position % colors.length;
convertView.setBackgroundColor(colors[colorPos]);
I hope it helps you.
Upvotes: 0
Reputation: 6602
Try this...
In your custom layout recognize your root element and set its background color.
linearLayout.setBackgroundColor(Color.WHITE);
Upvotes: 1
Reputation: 12367
You will have to create custom adapter, and configure individual views as you like. Keep in mind, that list views can be recycled for better performance
Upvotes: 0