如何使用addCommandToRightBar(Command)删除添加到工具栏的命令? [英] How to remove a command added to the Toolbar using addCommandToRightBar(Command)?

查看:41
本文介绍了如何使用addCommandToRightBar(Command)删除添加到工具栏的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用addCommandToRightBar(Command)将命令添加到工具栏后,我想再次删除或隐藏该命令(例如,当我在标签中的特定标签上选择/取消选择时)。在SideMenuBar中,有个removeCommand(Command),但是我不知道如何对工具栏做同样的事情。有什么建议可以实现这一目标吗?谢谢

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

推荐答案

removeCommand 可以使用,但是您应该记住 revalidate()

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();   

这篇关于如何使用addCommandToRightBar(Command)删除添加到工具栏的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆