avoiding selected group collapse when refreshing (using expandablelistview and cursor loaders

616 views Asked by At

I am pretty much following the example here SimpleCursorTreeAdapter and CursorLoader for ExpandableListView But I also have an async task running to update the database. I notice when I have a group expanded it collapses and then expands right before refreshing. I tracked it down and it seems to be in onLoadFinished right where setChildrenCursor is being set. How can I avoid the blinking while the data is being refreshed. I have looked around everywhere but nothing seems to address this particular problem. Any help appreciated.

1

There are 1 answers

0
Alexandr Plusnin On

I followed the same example and met the same problem. After hours of research I found out that blinking effect was caused by updating the table in database.

In order to prevent blinking, in adapter you need to override notifyDataSetChanged like this

@Override
public void notifyDataSetChanged() {
    notifyDataSetChanged(false);
}