[英]Codenameone Load overFlow menu
I have customized my form titlebar and added buttons to it. 我已经自定义了表单标题栏,并向其中添加了按钮。 Is it possible to add a listener to one of the buttons to add command(s) an overflow menu and show it. 是否可以在其中一个按钮上添加侦听器,以在溢出菜单中添加命令并显示它。
Yes, command/s can be added to overflow menu by using the following codes and actionPerformed is called when click on the command 是的,可以使用以下代码将命令添加到溢出菜单,并在单击命令时调用actionPerformed
Toolbar toolbar = new Toolbar();
f.setToolbar(toolbar);
toolbar.addCommandToOverflowMenu(new Command("Test") {
@Override
public void actionPerformed(ActionEvent evt) {
showForm("NewForm",null);
}
});
Please try this it displays overflow menu when you click on button.
void showOverFlow(final Form f) {
Toolbar toolbar = new Toolbar();
f.setToolBar(toolbar);
toolbar.addCommandToOverflowMenu(new Command("overflow"));
Button button = new Button("show menu");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (f.getToolbar() != null) {
MenuBar mb = f.getToolbar().getMenuBar();
if (mb != null) {
mb.showMenu();
}
}
}
});
toolbar.addComponent(BorderLayout.WEST,button);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.