android - How to prevent the RecyclerView from resorting while notifyDataSetChanged -
i use staggeredgridlayoutmanager recyclerview layout manager. when try load next page data , call notifydatasetchanged method update data, while scroll recyclerview, notice resort item.
i don't need resort it, how can prevent resorting. , wonder why resort.
thx!
@ershani gave valuable insight problem , adding more on top of it.
use notifydatasetchanged() last resort when using recycler view. notifydatasetchanged() following , quoting doc
this event not specify data set has changed, forcing observers assume existing items , structure may no longer valid. layoutmanagers forced rebind , relayout visible views.
if writing adapter more efficient use more specific change events if can. rely on notifydatasetchanged() last resort.
so in case if call notifydatasetchanged(), bound , visible layouts rebound pointless , ineffective.
you use notifyitemrangeinserted() after loading page. more effective , retains default animations provided recyclerview on data set changes.
Comments
Post a Comment