简体   繁体   English

如何使按钮像菜单一样起作用?

[英]How can I make a button act like a menu?

I am working on a simple application that is supposed to work on 800x480 tablet. 我正在一个应该在800x480平板电脑上工作的简单应用程序上工作。 Currently: 目前:
[][][][] [] [] [] []
[][][][] [] [] [] []
OOO OOO

These are all buttons and they are working as expected. 这些都是按钮,它们按预期方式工作。 I, however, need to add menu items to the bottom-buttons. 但是,我需要将菜单项添加到底部按钮。 When clicked, menu items should pop up. 单击时,菜单项应弹出。

-Can I create a menu and place it at the bottom of the screen to replace those buttons? -我可以创建一个菜单并将其放置在屏幕底部以替换那些按钮吗? If so, could you show an example, cause I couldn't find any. 如果是这样,您能举个例子,因为我找不到任何例子。

-Or, can I add menu items to these buttons? -或者,我可以向这些按钮添加菜单项吗?

What You want is an OptionsMenu, if I understand You the right way. 如果我以正确的方式理解您,那么您想要的是一个OptionsMenu。 I could give You an example later, I am not at home. 以后我可以举一个例子,我不在家。 But for now, look at this example. 但是现在来看这个例子。 If You follow this, You don´t need those buttons at the bottom. 如果您遵循此步骤,则不需要底部的那些按钮。

http://www.edumobile.org/android/android-beginner-tutorials/options-menu/ http://www.edumobile.org/android/android-beginner-tutorials/options-menu/

if it is not clear, just let me know and I try to give You an example at the evening... 如果不清楚,请让我知道,我尝试在晚上给您一个例子。

EDIT 编辑

for custom menu, You could use PopUpMenu. 对于自定义菜单,可以使用PopUpMenu。 I had not tried this for now, but I think it is a good solution 我暂时没有尝试过,但是我认为这是一个很好的解决方案

http://android-er.blogspot.de/2012/03/example-of-using-popupmenu.html http://android-er.blogspot.de/2012/03/example-of-using-popupmenu.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM