I have Listview with which I\'m trying to display my custom Adapter.Everything works fine except when I select list item and scroll it,the items which were not selected are alre
Another solution, put a simple int in your Custom list View
public class CustomListView extends BaseAdapter {
private int selected = 0;
check the position in your getView
public View getView(int position, View convertView, ViewGroup parent) {
if (position == selected)
selector.setImageResource(R.drawable.selected);
else
selector.setImageResource(R.drawable.not_selected);
and finally in the clickListener of your activity or fragment, set the position with setter/getter method and notify the adapter.
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
customListViewAdapter.setSelectedPosition(position);
customListViewAdapter.notifyDataSetChanged();
}
It works like a charm for me ;)