我正在尝试实施Android风格的侧边菜单,而且在添加sideCommands之前我在顶部和标签下方实现圆形图标时遇到问题。
我该如何实现?
答案 0 :(得分:2)
您可以使用工具栏API,它允许您将组件添加到Sidemenu。
查看Flickr demo。
您应该使用tool.addCommandToSideMenu(Command)
tool.addComponentToSideMenu(yourComponent, CommandToPerform)
示例:强>
@Override
protected void beforeMain(Form f) {
//Store your commands before setting toolbar
List<Command> cmds = new ArrayList();
for (int i = 0; i < f.getCommandCount(); i++) {
cmds.add(f.getCommand(i));
}
Toolbar toolbar = new Toolbar();
f.setToolBar(toolbar);
Label lblTitle = new Label("My Form", "Title");
lblTitle.setEndsWith3Points(false);
toolbar.setTitleComponent(lblTitle);
// Use your stored commands after setting toolbar
for (Command cmd : cmds) {
toolbar.addCommandToSideMenu(cmd);
}
Container CustomContainer = ...
toolbar.addComponentToSideMenu(CustomContainer, new Command("") {
@Override
public void actionPerformed(ActionEvent evt) {
//What CustomContainer should do (if any)
}
});
f.revalidate();
}