I have button, which displays a Context menu. In the menu are few items (some of them are disabled - setEnabled(false)).
Which event is called when a user click on the d
After consultation with my teacher, I've solved the problem. You can check the focus of your window, and then decide if the context menu was closed or not.
So you have to:
The code:
public class MyActivity extends android.app.Activity {
private boolean contextMenuDisplayed = false;
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus && this.contextMenuDisplayed) {
this.contextMenuDisplayed = false;
this.onContextMenuClosed(null);
}
}
public void onPrepareContextMenu() {
this.contextMenuDisplayed = true;
}
}