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

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -