Answer the question
In order to leave comments, you need to log in
How to find the desired fragment after changing the screen orientation?
Hello.
I have one activity and let's say 100 fragments.
After rotating the screen, how to display that fragment, the same fragment that was displayed before the device was rotated?
I do something like this in Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
...
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.my_layout);
if (fragment instanceof MyFragment1) {
goToMyFragment1();
} else if (fragment instanceof MyFragment2) {
goToMyFragment2();
} else if (fragment instanceof MyFragment3) {
...
}
}
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