title: MenuItem hidden in fragment not visible when doing setVisible(true) in main activity
body: <p>I have been stuck on this issue for quite a while now. In my code I have a fragment inside which I do not want to show the search menu item. To achieve that I do this inside the fragment</p>
  
  <p>Inside <code>onCreate</code></p>
  
  <pre><code>    setHasOptionsMenu(true);
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>@Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
          super.onCreateOptionsMenu(menu, inflater);
          this.menu = menu;
          MenuItem search = menu.findItem(R.id.action_search);
          search.setVisible(false);
      }
  </code></pre>
  
  <p>This works exactly as expected and hides the item. Now when i do back press the o<code>nBackPressed()</code> of the main activity is called and there I do this</p>
  
  <pre><code>@Override
  public void onBackPressed() {
  
      // code skipped
      invalidateOptionsMenu();
  } 
  </code></pre>
  
  <p>This calls the <code>onCreateOptionsMenu</code> inside the main activity which is as follows</p>
  
  <pre><code>@Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
  
          item = menu.findItem(R.id.action_search);
          item.setVisible(true);
  
         //code skipped
  }
  </code></pre>
  
  <p>The <code>onCreateOptionsMenu</code> function is called but unfortunately the <code>menuItem</code> still remains hidden, and I can't see the search menu.</p>
  
  <p>Can someone please help, what might be the issue? Thanks in advance !!</p>