Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codenameone 菜单按钮消失了_Codenameone - Fatal编程技术网

Codenameone 菜单按钮消失了

Codenameone 菜单按钮消失了,codenameone,Codenameone,当我打开菜单时,我试图开发一个带有滑动主屏幕的侧菜单。我遇到的问题是,当我关闭侧菜单时,菜单按钮消失。 在此处输入图像描述 Form hi = new Form("Hi World"); Toolbar tb = new Toolbar(false); Image icon = theme.getImage("icon.png"); Container topBar = new Container(new BorderLay

当我打开菜单时,我试图开发一个带有滑动主屏幕的侧菜单。我遇到的问题是,当我关闭侧菜单时,菜单按钮消失。 在此处输入图像描述

    Form hi = new Form("Hi World");
    Toolbar tb = new Toolbar(false);
    Image icon = theme.getImage("icon.png");
    Container topBar = new Container(new BorderLayout());
    topBar.add(BorderLayout.SOUTH, new Label("Cool App Tagline...", "SidemenuTagline"));
    topBar.setUIID("SideCommand");
    Command SideLogoCommand = new Command("");
    SideLogoCommand.setIcon(icon);
    
    Command MenuCommand = new Command("");
    
   
    
    Button HomeCommand= new Button("Home");
    HomeCommand.getAllStyles().setFgColor(0xA6A6A6);
    HomeCommand.addActionListener((evt) -> {
        SideMenuBar.closeCurrentMenu();
    });

    Button WebsiteCommand= new Button("Website");
    WebsiteCommand.getAllStyles().setFgColor(0xA6A6A6);
   
    Button SettingsCommand= new Button("Settings");
    SettingsCommand.getAllStyles().setFgColor(0xA6A6A6);

    Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    cnt.add(topBar);
    cnt.add(HomeCommand);
    cnt.add(WebsiteCommand);
    cnt.add(SettingsCommand);
    hi.setToolbar(tb);
    tb.setOnTopSideMenu(false);
    hi.addCommand(SideLogoCommand);
    MenuCommand.putClientProperty("SideComponent", cnt);
    tb.addCommandToSideMenu(MenuCommand);
    
    hi.addComponent(new Label("Hi World"));
    hi.show();

我猜是因为这句话:

tb.setOnTopSideMenu(false);
您实际上是在强制使用较旧的、测试较少的侧菜单,这些菜单在较新的代码中可能仍然存在回归。最好的办法是去掉那条线。但如果您坚持,您可以尝试调用:

hi.setAllowEnableLayoutOnPaint(true);
请注意,这将影响长表单等的性能