Codenameone 在何处保存代号为one的应用程序中的图像
我已经创建了一个单一的代码名一页(手动模板)。我可以在codename one app emulator中看到图像,但当我在Android手机上安装它时,它会在图像代码中显示Codenameone 在何处保存代号为one的应用程序中的图像,codenameone,Codenameone,我已经创建了一个单一的代码名一页(手动模板)。我可以在codename one app emulator中看到图像,但当我在Android手机上安装它时,它会在图像代码中显示java.lang.exception。这是我的密码: Form firstPage = new Form(); try { firstPage.getStyle().setBgImage(Image.createImage("src/com/acism/i
java.lang.exception
。这是我的密码:
Form firstPage = new Form();
try
{
firstPage.getStyle().setBgImage(Image.createImage("src/com/acism/images/low_poly_background.jpg"));
} catch (IOException ex) {
}
firstPage.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
Label logoLabel = null;
try {
logoLabel = new Label(Image.createImage("src/com/acism/images/logo.png"));
} catch (IOException ex) {
}
logoLabel.getStyle().setBgTransparency(0);
c.fill = GridBagConstraints.CENTER;
c.gridy = 0;
c.gridx = 0;
firstPage.addComponent(c, logoLabel);
Label name = new Label("Communication Is Important!");
name.getUnselectedStyle().setFgColor(0xFFFFFF);
name.getStyle().setBgTransparency(0);
c.fill = GridBagConstraints.CENTER;
c.gridy = 1;
c.gridx = 0;
firstPage.addComponent(c, name);
Button btn = new Button("Get Started");
btn.getUnselectedStyle().setBgColor(0x3083FF, true);
btn.getUnselectedStyle().setFgColor(0xFFFFFF);
c.fill = GridBagConstraints.CENTER;
c.gridy = 4;
c.gridx = 0;
btn.addActionListener(startedListener);
firstPage.addComponent(c, btn);
firstPage.show();
注:
图像存储在不同的包中。图像只能放在src目录的根目录中,因此如果logo.png存在,则类似于:
Image.createImage("/logo.png")
会有用的。然而,你不应该那样做强>
相反,您应该将图像放在res文件中,因为这意味着它们将动态地适应设备的DPI。太好了,谢谢Almog。你就是那个人。我还有一个问题,我在手动项目中工作,所以请告诉我,在手动模式下创建项目时,我在项目目录中没有看到任何res文件夹。您不需要res文件夹。只有src目录中的theme.res。