M
M
Maybe_V2016-04-27 21:17:07
Android
Maybe_V, 2016-04-27 21:17:07

How to control RecyclerView behavior?

When loading information from the network, 100 elements are placed in the RecyclerView, so when the end of the list is reached, another 100 are loaded, and so on.
But when adding new entries, the list is automatically reset to the beginning of the list. But I need it to stay in place, and the records were simply added, but nothing happened to the list!
My code
Question:
How to make RecyclerView open in a given position (well, or not run to the beginning when changing)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Myvrenik, 2016-04-27
@prokopov-vi

This happens because you recreate the adapter every time for some reason. You need to add new items to an already existing adapter and call the RecyclerView.Adapter#notifyItemRangeInserted() or RecyclerView.Adapter#notifyDatasetChanged() method after that.
What about moving to position: RecyclerView#scrollToPosition()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question