1

I have RecyclerView inside Fragment handled by ViewPager. How is it made that RecyclerView automatically restore its state after rotation? I thought I have to implement

LayoutManager.onSaveInstanceState()
LayoutManager.onRestoreInstanceState(Parcelable state);

by myself. Is LayoutManager or RecyclerView register some kind of onConfigurationChange receiver?

AppiDevo
  • 3,195
  • 3
  • 33
  • 51

1 Answers1

2

A RecyclerView extends a ViewGroup so, it's extend a View.

If you put an Id on your RecyclerView, the

onSaveInstanceState/onRestoreInstanceState

will be call.

Link : RecyclerView store / restore state between activities

Community
  • 1
  • 1
BenjaminBihr
  • 1,252
  • 2
  • 10
  • 15
  • As I said earlier there are no information about my question in the link you posted. Here is helpful link: http://trickyandroid.com/saving-android-view-state-correctly/ with great explanation how AUTOMATIC state saving works. – AppiDevo Mar 06 '17 at 13:46
  • Ok ! Your question is not only for recyclerView if I understand correctly – BenjaminBihr Mar 06 '17 at 13:52