I have a list view contactslist
. I wrote the code for highlighting the selected item in the ListView
. It is working. When I click on one item it is highlighting that item, but the problem is if I click on another item it is highlighting that one too. I want to highlight the selected item only. The previous selection should go away when I click on another item.
arg1.setBackgroundResource(R.drawable.highlighter);
This is the code in the click listener using to highlight the selected item. How can I fix this?
I'm setting the background of the rows in the adapter:
public int[] colors = new int[]{0xFFedf5ff, 0xFFFFFFFF};
public int colorPos;
[...]
colorPos = position % colors.length;
row.setBackgroundColor(colors[colorPos]);