I have a custom list view and I want the background of the list to be white, so I do something like this which works great.
listView = (ListView) this.findViewById(R.id.listview); listView.setBackgroundColor(Color.WHITE);
The problem is when you scroll the list the background of all the list items changes to black, which looks horrible.
I tried in my list view setting the background color to white. When I inflate the view I also tried setting the background color to white:
view.setBackgroundColor(Color.WHITE);
Both of these fix the problem of the scrolling background color, but now the item doesn't appear to be clickable even though it is. What I mean by that is the onClick still works fine, but the background doesn't flash to orange to let the user know he clicked it.
How can I have a white background in a list view, that stays white while scrolling, and does the normal list acitvity orange click background?
Thanks!
The solution is very simple, you also need to set the cache color hint to white: setCacheColorHint(Color.WHITE)
. You don't need to change the list items' background color.
ListView lv = getListView(); setCacheColorHint(0);
Set the cache color hint to zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With