How to remove a command added to the Toolbar using addCommandToRightBar(Command)?

戏子无情 提交于 2020-01-02 19:37:09

问题


after having added a command to the Toolbar using addCommandToRightBar(Command), I want to remove or hide the command again (e.g. when I select/unselect on a specific tab in Tabs). In the SideMenuBar there is removeCommand(Command) for this, but I can't figure out how to do the same for Toolbar. Any suggestions how I can achieve this? Thanks


回答1:


removeCommand works but you should remember to revalidate():

Toolbar.setGlobalToolbar(true);
Form hi = new Form("Bar");
Command cmd = hi.getToolbar().addCommandToRightBar("Bla", null, (e) -> Log.p("Bla"));
hi.getToolbar().addCommandToLeftBar("Remove", null, (e) -> {
    hi.removeCommand(cmd);
    hi.revalidate();
});

hi.show();   


来源:https://stackoverflow.com/questions/36293862/how-to-remove-a-command-added-to-the-toolbar-using-addcommandtorightbarcommand

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!