title: Hide options menu on PreferenceFragment
body: <p>I have an app with several fragments. </p>
  
  <p>Only A fragment has an options menu. 
  A fragment could be initiated from fragment B (which extends listfragment). </p>
  
  <p>So B fragment does not have an options menu, if I select some item from it, fragment A will be initiated with an options menu and if go back, fragment B still does not have an options menu. </p>
  
  <p>The problem is if I select Settings menu (which extends preferencefragment) from navigation drawer while my current window is fragment A, a settings fragment will be shown with options menu from fragment A. But if I select Settings menu from navigation drawer while my current window is fragment B, C, D (without options menu) everything works well.</p>
  
  <p>Fragment A:</p>
  
  <pre><code>@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
      super.onCreateOptionsMenu(menu, inflater);
  
      inflater.inflate(R.menu.menu_station, menu);
  }
  </code></pre>
  
  <p>Settings fragment:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setHasOptionsMenu(true);
  
      sharedPreferenceSettings = new SharedPreferenceSettings(getActivity());
  
      addPreferencesFromResource(R.xml.settings);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      return inflater.inflate(R.layout.fragment_settings, container, false);
  }
  </code></pre>
  
  <p>Where is the problem?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>After hours of debugging I found a solution. The problem was different fragmentManager for fragments transaction. For settings fragment only I used getSupportFragmentManager(), for others - fragmentManager(). This causes some fragments from moving to back stack.</p>