答案 0 :(得分:1)
您需要先将命令转换为组件:
Command cmd = tb.addMaterialCommandToRightSide(...);
Button btn = tb.findCommandComponent(cmd);
Container cnt = btn.getParent();
btn.remove();
FloatingActionButton fab = FloatingActionButton.createBadge("" + number);
cnt.add(badge.bindFabToContainer(btn, Component.RIGHT, Component.TOP));
请注意,此操作只能使用一次,因此,如果要更新编号,则需要在此处保存一些组件并删除/替换它们。