I have an Activity in which there is a TabLayout with 3 fragments. When switching to a new snippet, I need to update the menu for my toolbar. The menu is updated but not the first time. First you need a couple of times on the tabs to go, so that the menu would be updated later. Did not find information about this in google.

Here is how I update the menu:

@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); inflater.inflate(R.menu.fm_fragment_menu, menu); super.onCreateOptionsMenu(menu, inflater); } 
  • setHasOptionsMenu(true) cause when creating a fragment? super.onCreateOptionsMenu(menu, inflater) does not need to be called in this method. - pavlofff
  • setHasOptionsMenu (true) I call - Nick
  • I tried to do it differently, via setVisible (), but the result is the same. When you go to a fragment of the menu does not appear the first time, and even with a delay - Nick
  • Did you try to remove the super-method call at the end? - pavlofff
  • Yes, everywhere removed, does not work. Still, this information may help. My TabLayout is connected with ViewPager - Nick

0