Search code examples
androidandroid-optionsmenu

Fragment onCreateOptionsMenu not getting called on orientation change


I have a activity having multiple fragments in viewpager. When I open option menu it adds menu items from particular fragment to option menu. I am using android 4.2 and has android:configChanges="orientation" I have not added screensize due to which activity will be created on orientation change which I want.

When I open option menu all menus including fragment menu items are shown. But if I rotate device while option menus is showing only option menu items of activity are shown. I checked it is because fragment onCreateOptionsMenu is not called when I change orientation. How can I add fragment option menu items to already shown option menu while changing orientation .


Solution

  • Done by calling setMenuVisibility(true); in onResume of my Fragment class.