I have an activity that registers a list view for the creation of the context menu:
registerForContextMenu(getListView());
The problem is that a long click on some items should not present the context menu, because the items are disabled.
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
bool bDisplayMenu = isItemEnabled(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
if(bDisplayMenu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
else
{
// WHAT SHOUlD I DO HERE TO CANCEL THE CREATION OF THE CONTEXT MENU?
}
}
I don't see any way to cancel the creation of the context menu once onCreateContextMenu() has been called.