Answer the question
In order to leave comments, you need to log in
How to make Fragment#onSaveInstanceState be called when switching fragments in NavigationDrawer?
I generated a project in AndroidStudio with NavigationDrawer.
How to follow so that when switching between fragments, the onSaveInstanceState method is called in the current fragment. So that when switching back, restore the state of the fragment.
Fragments switch like this:
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
.commit();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question