I\'ve prepared a custom listview using BaseAdapter. Now I want to change color of selected item of listview on click event. And multiple items should be selected. Here I am
Its very simple... Just try the following code...
In your List Adapter:
Define an Integer Array first
ArrayList itemPos = new ArrayList();
then use this code in your getView Method :
if (itemPos.contains(position)) {
holder.txtOne.setTextColor(Color.BLUE);
} else {
holder.txtOne.setTextColor(Color.WHITE);
}
Now use this code in click event of your Text View :
if (!itemPos.contains(position)) {
holder.txtOne.setTextColor(Color.BLUE);
itemPos.add(position);
notifyDataSetChanged();
} else {
holder.txtOne.setTextColor(Color.WHITE);
notifyDataSetChanged();
int po = itemPos.indexOf(position);
itemPos.remove(po);
}