Making a Custom Menu in Android
I'm working on making a game for the android, with a friend doing the artwork. My friend wants to do his own menu, as in, he made an image to be used as the menu.
My question is, is there a way to have onMenuOpened() activate upon pressing the menu but开发者_开发技巧ton with no menu items in onCreateOptionsMenu(), and then from my SurfaceView class close the menu? Or simply, how can I do my own menu that's activated upon pressing the menu button?
You probably could use Activity onKeyDown() function and detects KeyEvent.KEYCODE_MENU and do what you want.
Your code should be something like:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
// Do your own menu here
return true;
}
return false;
}
精彩评论