I'm using ActionBarSherlock and trying to inflate my XML menu by using getSupportMenuInflator()
, but it is giving an error:
the method getSupportMenuInflator() is undefined for the type ...
I'm unable to figure out why it's showing the error. Here is the code:
public void onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.activity_main, menu);
...
}
How do I fix it?
You need to use:
getSherlockActivity().getSupportMenuInflater().inflate(R.menu.activity_main, menu);
Since getSupportMenuInflater()
is a method in SherlockActivity not SherlockFragment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With