如何仅以特定形式显示侧边菜单图标

How to show side menu icon in particular forms only

我的应用程序中有侧边菜单。但是由于我在标题栏中有很多图标,所以我只想以特定形式保留侧面菜单图标。我从主题常量中使用了 hideLeftSideMenuBool true 但图标从所有表单中消失了。

更新1:图标出现在侧面菜单本身的底部,没有用。它应该出现在工具栏/标题栏。

@Override
protected void beforeMenuForm(Form f) {
    Toolbar t = new Toolbar();
    t.setUIID("TitleArea");
    f.setToolBar(t);
    Label titleIcon = new Label();
    titleIcon.setIcon(theme.getImage("app-icon.png").scaledHeight(t.getHeight() + 50));
    titleIcon.setUIID("smallFont");
    t.setTitleComponent(titleIcon);

    showAllCommands(f);

    //the icon appears at the bottom of side menu itself that is of no use
    f.getToolbar().addMaterialCommandToSideMenu("", FontImage.MATERIAL_MENU, e -> ((SideMenuBar)f.getMenuBar()).openMenu(null));
}

public void showAllCommands(Form f) {
   Command home = new Command("  Home", homeIcon) {

        @Override
        public void actionPerformed(ActionEvent evt) {
            showForm("MenuForm", this);
        }
    };
    f.addCommand(home);
}

隐藏侧边菜单标志是全局的。

仅当您将 commands/components 添加到侧边菜单时,该菜单才会出现。如果您不添加它们,它将不会显示。

如果您希望菜单按钮只出现在某些表单上,您需要完全禁用它并在要显示的表单左侧添加一个您自己的菜单按钮。这样的事情应该有效:

toolbar.addMaterialCommandToLeftSide("", FontImage.MATERIAL_MENU, e -> toolbar.openSideMenu());