Is it possible to apply a custom background to each Listview item via the list selector?
The default selector specifies @android:color/transparent
for t
The solution by dglmtn doesn't work when you have a 9-patch drawable with padding as background. Strange things happen, I don't even want to talk about it, if you have such a problem, you know them.
Now, If you want to have a listview with different states and 9-patch drawables (it would work with any drawables and colors, I think) you have to do 2 things:
What you should do is first set the row_selector.xml:
Don't forget the android:state_selected
. It works like android:state_focused
for the list, but it's applied for the list item.
Now apply the selector to the items (row.xml):
...
Make a transparent selector for the list:
This should do the thing.