How to dynamically remove items from ListView on a button click?
Solution 1:
Well you just remove the desired item from the list using the remove()
method of your ArrayAdapter
.
A possible way to do that would be:
Object toRemove = arrayAdapter.getItem([POSITION]);
arrayAdapter.remove(toRemove);
Another way would be to modify the ArrayList
and call notifyDataSetChanged()
on the ArrayAdapter
.
arrayList.remove([INDEX]);
arrayAdapter.notifyDataSetChanged();
Solution 2:
This worked for me. Hope it helps someone. :)
SimpleAdapter adapter = (SimpleAdapter) getListAdapter();
this.resultsList.remove((int) info.id);
adapter.notifyDataSetChanged();