title: Clear Toolbar menu options added by fragment when it is replaced
body: <p>I have a set up of 3 'top-level' fragments that each use their own Child Fragment Managers to offer drill-down navigation. These top-level fragments are switched around by being replaced using the main activity's Support Fragment Manager.</p>
  
  <p>One of this top-level fragments has a child fragment that adds a menu option to the toolbar/actionbar using <code>setHasOptionsMenu()</code> and <code>onCreateOptionsMenu()</code> and that works just fine.</p>
  
  <p>Now the issue I just noticed is this:</p>
  
  <p>When a new child fragment is added and the child fragment with the menu item is hidden (and the transaction added to the backstack of the top-level fragment), the menu item goes away. Similarly, when the fragment is visible again by undoing the transaction, the menu item comes back. This is desired behavior and seems to be handled entirely by the Fragment framework.</p>
  
  <p>HOWEVER, <strong>if the child fragment is visible (and thus, its menu item is present in the toolbar) and I switch top-level fragments, the menu item remains in the toolbar</strong>.</p>
  
  <p>I would have expected the menu item to be cleared as not only the child fragment it belongs to has been dumped, but even its parent fragment (on of the top-level fragments) has also been completely replaced (not even added to the backstack, just straight up replaced).</p>
  
  <p>I figure I could just call <code>invalidateOptionsMenu()</code> on the activity whenever the incoming top-level fragment has Resumed, but I feel like there is just something I am missing for it to be handled automatically like when navigating within the top-level fragment.</p>