Jesse Jashinsky
Jesse Jashinsky

Reputation: 10683

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 button 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?

Upvotes: 1

Views: 538

Answers (1)

momo
momo

Reputation: 21353

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;
    }

Upvotes: 1

Related Questions