I want to open up the options menu by clicking on开发者_JAVA技巧 my own created button; is this possible?
If you don't want to use the button of the phone, you have to do the following :
define a listener on your button:
openMenuButton = (Button) findViewById(R.id.yourButton);
openMenuButton .setOnClickListener(this);
and then in the method onClick(), add :
openOptionsMenu()
Use the openOptionsMenu()
method of your Activity
to open the Menu programatically.
Still, what Nikola said is right - you'd be better conforming with Android's guidelines.
精彩评论