I am trying to get the menu inflater inflate the menu xml in my SherlockActivity class.
My onCreateOptionsMenu method is like this -
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
MenuInflater inflater = this.getSupportMenuInflater();
inflater.inflate(R.menu.messagespagemenu, menu);
return true;
}
and my messagespagemenu.xml looks like this -
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/text"
android:title="@string/deleteall">
</item>
And my activity class extends SherlockActivity.
Could anyone please point me to the mistake I am doing.
EDIT:
The menu is not showing. When I try this same code in another class is extending SherlockListActivity then it works. So I am wondering if I am missing anything in this class
Probably you are running this on a pre-Honeycom device, and this MenuItem will be shown just if you click the hardware menu key. You should set android:showAsAction:alwaysor android:showAsAction:ifRoom on your <item>.
EDIT: you should also make the call to super.onCreateOptionsMenu()
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