I’m having type issues when attempting to inflate a ContextMenu while making use of the ActionBarSherlock library, which as you know ultimately mimics/implements the Android support library.
There is a SherlockFragmentActivity which sets the layout content and within that content exists two fragments. One of those fragments is a SherlockListFragment. Within the onCreate of the SherlockListFragment I make a call to register for the ContextMenu.
registerForContextMenu(getListView());
The problem stems when attempting to inflate the menu.
listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
MenuInflater inflater = getSherlockActivity().getSupportMenuInflater();
inflater.inflate(R.menu.lot_menu, contextMenu);
}
});
I am unable to call inflate due to the type specified within the method parameters, which it expects as com.actionbarsherlock.view.Menu however the passed in type is android.view.ContextMenu.
I seem to be missing something as inflating a Menu within the action bar was trivial however the ContextMenu seems to be posing issues when making use of the support framework.
How do I register appropriately to make use of the support framework as needed and subsequently inflate the ContextMenu?
Try using
getMenuInflater()instead ofgetSupportMenuInflater()for inflating into aContextMenu.