Sam
Sam

Reputation: 351

Getting the ListView to reload it's Views

The situation:
I have an activity with a spinner and a list with a BaseAdapter.

The list is loaded once, and shows correctly... But when I click on the spinner to change the underlying data and call adapter.notifyDataSetChanged(); the list doesn't refresh.

By this I mean that the data is changed and the adapter has the right data, it's just that the listView doesn't change the view.

How to force the listViews to show the right data?

Upvotes: 1

Views: 276

Answers (2)

Todd Davies
Todd Davies

Reputation: 5522

Try adapter.notifyDataSetInvalidated(); as well as adapter.notifyDataSetChanged();


EDIT: Clear your ArrayList or whatever you're using before you add more items with something like .clear(); and then add the new items and call adapter.notifyDataSetChanged();

Upvotes: 2

Nermeen
Nermeen

Reputation: 15973

Try

myListView.invalidateViews();

Upvotes: 0

Related Questions