I have a listview and when it is clicked then it has to be invisible. It works perfectly fine but when the screen is scrolled up and down those which are invisible again reappears. Does anybody know how to fix these.
Here is my code snippets for the ListItemClick
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
v.setVisibility(View.GONE);
Object o = this.getListAdapter().getItem(position);
Contact1 c = (Contact1) o;
Toast.makeText(this, c.getDisplayName(),
Toast.LENGTH_SHORT).show();
Toast.makeText(this, c.getId(), Toast.LENGTH_SHORT).show();
ids.add(c.getDisplayName());
}
It happens because every time the list is scrolled , the listview’s adapter’s
getView()method gets called where the listitems are generated again. SO for your need you need to have a custom adapter and override itsgetViewmethod, and in it