I have a host acitivity with two fragments; fragment A having a recyclerview of items, and fragment B for displaying the details..
when a user click on an item, fragment A gets replaced for fragment B;
I want to save the position of the recyclerview when items are clicked..
I have trying the following..
if Fragment A..
Parcelable recyclerViewState;
in onPause I'm assigning a value for the variable as follow:
@Override
public void onPause() {
super.onPause();
recyclerViewState = imagesRecyclerView.getLayoutManager().onSaveInstanceState();
}
in onResume I'm retrieving the value as follows:
@Override
public void onResume() {
super.onResume();
if (recyclerViewState != null) {
imagesRecyclerView.getLayoutManager().onRestoreInstanceState(recyclerViewState);
}
}
however it's not working yet?