androidandroid-recyclerviewlinearlayoutmanager

Save Position of RecylerView when we go to Detail Activity by clicking from list of items in RecyclerView and restore it when we back to RecylerView


How to Save Scroll Position of RecylerView Activity when we go to next Detail Activity by using itemclicklistener from list of items(these items are retrieved from Firebase JSON) in RecyclerView and restore position when we come back to Recylerview Activity and i am Using LinearLayoutManager

Please Help Me Thanks in Advance


Solution

  • I am not really clear with your question. I assumed you current activity was destroyed when you go to next detail, thus recreating the activity when you go back. Do not call finish when you go to next detail and just call onBackPressed to go back to your previous activity. This will maintain your recyclerView state and position.

    Anyway, you can use Shared Preferences to save the position before go to next detail and get it back on onResume.