ListViews and GridViews are great widgets to use in an Activity for your app. Sometimes it is useful to also create smaller versions of them for dialogs within your app. There’s only one problem: Context Menus. If you have tried to put a context menu on a ListView inside a dialog, you may have found out that while onCreateContextMenu() is called, onContextItemSelected() is not. There is a workaround, though, because onContextItemSelected() is actually a convenience method called from onMenuItemSelected(int, MenuItem). If you add the following method to your dialog containing the ListView (or GridView), you will find that onContextItemSelected() is working again.
@Override public boolean onMenuItemSelected(int aFeatureId, MenuItem aMenuItem) { if (aFeatureId==Window.FEATURE_CONTEXT_MENU) return onContextItemSelected(aMenuItem); else return super.onMenuItemSelected(aFeatureId, aMenuItem); }