繁体   English   中英

我在将 SideMenu 添加到我的应用程序时遇到问题

[英]I have problem with add SideMenu my application

当我使用代码添加 SideMenu 我无法 java 给我你有问题但我无法解决问题在此处输入图像描述

可以帮助我修复代码或给我另一个代码。

Form hi = new Form("Hi World");
Toolbar tb = hi.getToolbar();
Image icon = theme.getImage("mu.png");
Container topBar = BorderLayout.east(new Label());
topBar.add(BorderLayout.SOUTH, new Label("Cool App
 Tagline...", "SidemenuTagline","));
topBar.setUIID("SideCommand");
tb.addComponentToSideMenu(topBar);
tb.addMaterialCommandToSideMenu("Home", FontImage.MATERIAL_HOME, e ->
 {});
tb.addMaterialCommandToSideMenu("Website", FontImage.MATERIAL_WEB, e ->
 {});
tb.addMaterialCommandToSideMenu("Settings", FontImage.MATERIAL_SETTINGS, e
 -> {});
tb.addMaterialCommandToSideMenu("About", FontImage.MATERIAL_INFO, e ->
 {});
hi.addComponent(new Label("Hi World"));
hi.show();

theme是应该已经创建的资源文件。 如果您在主 class 中,则由于创建主 class, theme变量应该已经存在。 如果没有,您可以通过在代码之前添加此行来在方法的主体中创建它:

Resources theme = getGlobalResources();

请注意,您需要使用设计器工具或 CSS 将图像mu显式添加到 res 文件中...

我还注意到您对此代码有后续问题:

topBar.add(BorderLayout.SOUTH, new Label("Cool App
 Tagline...", "SidemenuTagline","));

在 Java 中,您不能在中间断开字符串,如果要添加换行符,则需要使用\n

topBar.add(BorderLayout.SOUTH, new Label("Cool App\nTagline...", "SidemenuTagline","));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM