Mike Litoris :
I'm using a RecyclerView and .notifyItemInserted
only inserts one item into the RecyclerView. How would I do that say, for multiple items? I want to AVOID using .notifyDataSetChanged()
.
Say I have 25 items
, I want to insert another 20
, what method would I call?
Md. Asaduzzaman :
You can use notifyItemRangeInserted
to notify for multiple insertion.
void notifyItemRangeInserted (int positionStart, int itemCount)
According official documentation
Notify any registered observers that the currently reflected
itemCount
items starting atpositionStart
have been newly inserted. The items previously located atpositionStart
and beyond can now be found starting at positionpositionStart + itemCount
.