Whenever a user presses on the listview, it changes its background color to red. However, when i press another item, the old item still retains the background color of red. How to edit it such that only the clicked item has the background color changed.
lvContact.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
view.setSelected(true);
view.setBackgroundColor(Color.RED);
nameSelected = contactHolderArrayList.get(position).name;
phoneSelected = contactHolderArrayList.get(position).phone;
//Anything
}
});