简体   繁体   English

在 codenameone 项目中 - 如何以编程方式从项目资源文件夹中获取图像?

[英]In a codenameone project - How can I get images programmatically from the project resources folder?

CodenameOne changed the project structure after the maven dependence manager passed to be used as the new standard for dependence management. CodenameOne在maven依赖管理器通过后改变了项目结构,作为依赖管理的新标准。

Now exists a new folder called resources at the same level as the java folder.现在存在一个名为 resources 的新文件夹,与 java 文件夹处于同一级别。 (in project structure) (在项目结构中)
I put my images inside the /resources/images.我将我的图像放在 /resources/images 中。

How can I get these images programmatically?如何以编程方式获取这些图像? I tried some java common approaches without success.我尝试了一些 java 常用方法但没有成功。

Don't put the images in a folder under resources.不要将图像放在资源下的文件夹中。 Put them directly in common/src/main/resources then access them using /imagename.png as you always have.将它们直接放在common/src/main/resources中,然后像往常一样使用/imagename.png访问它们。

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

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