ScrollToPosition for Lazy Loading RecyclerView
0 I'm trying to build a simple activity for messaging in android. I have a RecyclerView that list the messages and I set a ScrollListener on it. When the firstVisibleItem is the third of the list (RecyclerView stack from end) , I will make a call to load other elements. I add this element to my array and I set a new adapter on my RecyclerView for the update. When I set the new adapter, the list starts one more time from the last message. So far I have tried to use scrollToPosition to go to the message where the user was before scrollListener was triggered, but still not work at all because the lastVisibleItem become 1 every time. Is there a way to maintain the last firstVisible element and set this element as the top element after reset the Adapter? This is the onCreateMethod . @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.chat); lastOffset = 0; requestSize = 20; loadMessage(...