带有标题和可滚动内容的工具栏侧边菜单
Toolbar sidemenu with title and scrollable content
我想创建一个带有标题和可滚动内容的侧边菜单。
我也尝试了一些东西:
//that works: i can scroll in the content container and the status label stay on top but it's in my welcome form
Form welcome = new Form("Welcome");
welcome.setLayout(new BorderLayout());
Label welcomeStatusLabel = new Label("STATUS");
Container welcomeContent = new Container(new BoxLayout(BoxLayout.Y_AXIS));
welcomeContent.setScrollableY(true);
for(int i=0; i<20; i++)
welcomeContent.add(new Label("Item "+i));
welcome.add(BorderLayout.NORTH,welcomeStatusLabel);
welcome.add(BorderLayout.CENTER,welcomeContent);
现在我想在我的侧边菜单中有同样的行为,我尝试这样做:
//that doesn't work: I can't scroll
Form menu= new Form("Menu");
menu.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
for(int i=0; i<20; i++)
menu.add(new Label("Item "+i));
welcome.getToolbar().addComponentToSideMenu(menu);
也许我不能在我的工具栏侧边菜单中放置一个表单,所以我尝试使用一个容器:
//that doesn't work: the status label will scroll with the content
Container menuContainer = new Container(new BorderLayout());
menuContainer.add(BorderLayout.NORTH,new Label("MENU STATUS"));
Container menuContent = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for(int i=0; i<20; i++)
menuContent.add(new Label("Item "+i));
menuContainer.add(BorderLayout.CENTER,menuContent);
//if I uncomment these two lines the content won't scroll anymore on simulator. On android it scrolls with the status label
//menuContainer.setScrollableY(false);
//menuContent.setScrollableY(true);
welcome.getToolbar().getMenuBar().setScrollableY(false);//I don't know what that line does
welcome.getToolbar().addComponentToSideMenu(menuContainer);
也许我不应该在侧边菜单中这样做?或者我没有使用正确的组件?
如有任何帮助,我们将不胜感激。
此致。
乔纳斯
您不应将 Form
添加到另一个组件中,而不是添加到侧边菜单中。
如果您只是想让侧边菜单看起来像表单标题区域,您可以这样做:
SpanLabel fakeTitle = new SpanLabel("My Title", "Title");
fakeTitle.setUIID("TitleArea");
welcome.getToolbar().addComponentToSideMenu(fakeTitle);
不过我不会那样做。查看一些 our demos 的精美侧边菜单设计。
我想创建一个带有标题和可滚动内容的侧边菜单。 我也尝试了一些东西:
//that works: i can scroll in the content container and the status label stay on top but it's in my welcome form
Form welcome = new Form("Welcome");
welcome.setLayout(new BorderLayout());
Label welcomeStatusLabel = new Label("STATUS");
Container welcomeContent = new Container(new BoxLayout(BoxLayout.Y_AXIS));
welcomeContent.setScrollableY(true);
for(int i=0; i<20; i++)
welcomeContent.add(new Label("Item "+i));
welcome.add(BorderLayout.NORTH,welcomeStatusLabel);
welcome.add(BorderLayout.CENTER,welcomeContent);
现在我想在我的侧边菜单中有同样的行为,我尝试这样做:
//that doesn't work: I can't scroll
Form menu= new Form("Menu");
menu.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
for(int i=0; i<20; i++)
menu.add(new Label("Item "+i));
welcome.getToolbar().addComponentToSideMenu(menu);
也许我不能在我的工具栏侧边菜单中放置一个表单,所以我尝试使用一个容器:
//that doesn't work: the status label will scroll with the content
Container menuContainer = new Container(new BorderLayout());
menuContainer.add(BorderLayout.NORTH,new Label("MENU STATUS"));
Container menuContent = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for(int i=0; i<20; i++)
menuContent.add(new Label("Item "+i));
menuContainer.add(BorderLayout.CENTER,menuContent);
//if I uncomment these two lines the content won't scroll anymore on simulator. On android it scrolls with the status label
//menuContainer.setScrollableY(false);
//menuContent.setScrollableY(true);
welcome.getToolbar().getMenuBar().setScrollableY(false);//I don't know what that line does
welcome.getToolbar().addComponentToSideMenu(menuContainer);
也许我不应该在侧边菜单中这样做?或者我没有使用正确的组件?
如有任何帮助,我们将不胜感激。
此致。
乔纳斯
您不应将 Form
添加到另一个组件中,而不是添加到侧边菜单中。
如果您只是想让侧边菜单看起来像表单标题区域,您可以这样做:
SpanLabel fakeTitle = new SpanLabel("My Title", "Title");
fakeTitle.setUIID("TitleArea");
welcome.getToolbar().addComponentToSideMenu(fakeTitle);
不过我不会那样做。查看一些 our demos 的精美侧边菜单设计。