Reputation: 9
Navigation Drawer have 4 fragment A,B,C,D On moving from A to B want to save the list maintain in A.
onDestroyView is called but unable to pass arguments in that.
Upvotes: 0
Views: 320
Reputation: 1061
Save instant of fragment by override onSaveInstanceState of fragment and restore on onActivityCreated, follow this
@Override
public void onSaveInstanceState(Bundle outState) {
//Save the fragment's state here
super.onSaveInstanceState(outState);
}
and
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
//Restore the fragment's state here
}
}
Upvotes: 1
Reputation: 1977
you can use
fragmentTransaction.addToBackStack(tag);
it will save each
getSupportFragmentManager().popBackStack();
Upvotes: 0