Reputation: 175
I made an onTouchListener to a list view that checks which item (string in my case) in that list was clicked and it's position. I want to take out that string of the list, so I made a method that gets the array adpter's string array and the poistion the list was touched and returns a new array that is the same but without the string that was touched. now I want to update the list view adapter to the new array, how do I do that? thanks
Upvotes: 0
Views: 454
Reputation: 11439
What you have to do is set a change notification to the array adapter via the BaseAdapter.notifyDatasetChanged. This will refresh the entire list view. Note: this must be called in the main thread.
EDIT:
To clear some confusion you have to first fetch the Adapter from your list view. This is done by calling myListView.getAdapter(). So you could do
myListView.getAdapter().notifyDatasetChanged()
Upvotes: 3
Reputation: 7067
You should try to set the array in your adapter again.
listView.setAdapter(new YourAdapter(this, yourArray));
Upvotes: 0