I know it sounds very simple, and there are questions about this. But none of it could solve my problem. So here we go:
I want to change background color of a list item
What I do is I create an xml file called i.e. list_background and put it in the drawable folder.
The xml looks like this:
And in the xml code for the ListView's item I put this xml as the items background i.e.
item.xml:
style=@style/Fill is only a short cut i made for android:layout_height="match_parent" and android:layout_width="match_parent
Then in onListItemCLick:
public void onListItemClick(ListView l, View v, int position, long id) {
v.setPressed( !v.isPressed ) //Toggle between colors of the view
}