4

I implemented an Activity (A) that displays only one fragment (PF) with getSupportFragmentManager(). Fragment (PF) has one ViewPager to display 2 Fragments (F1 and F2). ViewPager uses FragmentPagerAdapter with getChildFragmentManager().

Relative Code (ViewPagerActivity)

PF has setRetainInstance(true) and I added setHasOptionsMenu(true) to PF, F1 and F2 because they have personalize optionmenus.

Everything works fine. When I swype between F1 and F2 actionbar changes showing optionmenu 1 or optionmenu 2, but when screen rotation happens optionmenus in fragments 1 and 2 are no longer called after swype.

LOG_TAG
  • 19,894
  • 12
  • 72
  • 105

1 Answers1

0

You need to add setRetainInstance(true) to F1 and F2 too. Since fragments can have their own option menus you have to tell android that it should retain your child fragments too and not just the parent fragment.

showp1984
  • 378
  • 1
  • 2
  • 13