title: android getMenuInflater() in a fragment subclass - cannot resolve method
body: <p>I am trying to inflate a menu in a class that inherits the <code>Fragment</code> class.
  Here is my <code>OnCreateOptionsMenu()</code> method -</p>
  <pre><code>@Override
  public boolean OnCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.forecastfragment, menu) ;
      return true;
  }
  </code></pre>
  <p>This raises the following error:</p>
  <blockquote>
  <p>Cannot resolve method 'getMenuInflater()'</p>
  </blockquote>
  <p>I tried :</p>
  <pre><code>MenuInflater inflater = getActivity().getMenuInflater();
  </code></pre>
  <p>but then Android Studio highlights <code>@Override</code> in red and states:</p>
  <blockquote>
  <p>Method does not override method from its superclass</p>
  </blockquote>
  <p>I also tried to create a <code>getMenuInflater</code> method in the same class and have it return <code>new MenuInflater(this)</code></p>
  <pre><code>public MenuInflater getMenuInflater() {
      return new MenuInflater(this);
  }
  </code></pre>
  <p>but then the following error is thrown :</p>
  <blockquote>
  <p>error: incompatible types: ForecastFragment cannot be converted to
  Context</p>
  <p>error: method does not override or implement a method from a supertype</p>
  </blockquote>
  <p>What do I do?</p>