I have a ListView(first) and I am setting adapter on it on first time when activity starts and when a user selects some options from the menu. I have another list(second) on same activity which shows downloading progress for some items. I have started a repeating task to update this ListView to update progress in each item. Now the problem is if I select any option from menu to change the first list adapter it will invalidate as required. But if there are some items in my second ListView which have downloaded then selecting an option from menu to change adapter on first list just display a blank list.
But when I drag on the list all items display. I am not getting where the problem is. Please help.
I just faced the problem and found what was wrong. It basically means that ListAdapter.notifyDataSetChanged()
has not been called on the main thread.
It means it occurs by changing the adapter data not on the main thread. For example calling ArrayAdapter.add()
.
The solution is simple. Put your adapter data changing method on the main thread. For example you can do:
Activity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.notifyDataSetChanged();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With