I am implementing a context menu for my main activity. I have some XML to define the items:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:title="@string/random_item"
android:id="@+id/random_item"
android:icon="@drawable/random"/>
<item
android:title="@string/about_item"
android:id="@+id/about_item"
android:icon="@android:drawable/ic_menu_info_details"/>
</menu>
I have this code to create the menu:
@Override public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.main, menu);
return (super.onCreateOptionsMenu(menu));
}
And I have implemented onContextItemSelected to get my callbacks:
@Override public boolean onContextItemSelected (MenuItem item)
{
// do some stuff
}
When I click the menu button, my context menu appears with the appropriate items and icons. When I select a menu item, I don't get the callback. What am I missing here?