Petros Mosoyan
Petros Mosoyan

Reputation: 248

Recycler view starts auto scroll when new list is added

I have an problem with implementation of recycler view. I'm using listadapter with recyclerview. Everythings work perfectyl unitl I'm changing arraylist items order. When I'm changing the items order and submit it to adapter the recycler view makes scroll. For examle if i reverse the arraylist , its scrolling to the bottom.

How to disable auto scrol or keep recyclerview scroll position when the sort orders is changed.

Upvotes: 2

Views: 1539

Answers (1)

Devarshi Rawal
Devarshi Rawal

Reputation: 53

There are two possible ways to solve this issue. Please try them :-

  1. You can use notifyItemRangedChanged(fromIndex,toIndex);.

  2. You can use RecyclerView.scrollToPosition(0); when sort orders are changed.

Thank you!

Upvotes: 0

Related Questions