开发者

Options menu in an Android application

开发者 https://www.devze.com 2022-12-23 02:31 出处:网络
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 :

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号