问题描述
我如何获得与黑莓Eclipse插件测试版1.1捆绑图像?我要复印的图像为RES / background.jpg,并试图用 Bitmap.getBitma $ P $的PSource
上background.jpg加载它。不幸的是,图像没有被发现(非法参数异常)。我试图移动我的图像文件到src文件夹as每这里的建议,但是这也不能工作。我已经打开了.jar文件和背景图像是.jar文件的根目录present。在option转换图像文件的.png 也不会被选中。
How do I get bundled images with the BlackBerry Eclipse Plugin 1.1 Beta? I copied an image into "res/background.jpg" and tried to load it using Bitmap.getBitmapResource
on background.jpg. Unfortunately, the image wasn't found (Illegal argument exception). I tried moving my image file into the src folder as per the advice here, but that didn't work either. I have opened up the .jar file and the background image is present at the root of the .jar file. The option to convert image files to .png isn't selected either.
链接
- Could not find sample
- Library Reference
推荐答案
两件事情:
- 的
RES
文件夹需要在Eclipse中源目录。您可以通过在文件夹上单击鼠标右键,并要构建路径实现这一目标 - >作为源使用文件夹 - 致电时
Bitmap.getBitma $ P $的PSource()
,像迈克尔B.上面说的,你不应该把文件夹名称中的路径。只需拨打Bitmap.getBitma $ P $的PSource(background.jpg);
- The
res
folder needs to be a "source directory" in Eclipse. You can achieve this by right-clicking on the folder and going to "Build Path" -> "Use As Source Folder". - When calling
Bitmap.getBitmapResource()
, like Michael B. said above, you shouldn't put the folder name in the path. Just callBitmap.getBitmapResource("background.jpg");
最后,我假设,因为你的资源被称为background.jpg你希望它是一个屏幕的背景。如果是这种情况,请务必使用设置屏幕的的主要管理器的,而不是屏幕本身的背景。例如:
Finally, I'm assuming that because your resource is called "background.jpg" you want it to be the background for a Screen. If this is the case, make sure to set the background using the Screen's Main Manager instead of on the screen itself. For example:
public class MyScreen extends MainScreen
{
public MyScreen() {
getMainManager().setBackground(
BackgroundFactory.createBitmapBackground(
Bitmap.getBitmapResource("background.jpg")));
}
}
这篇关于与黑莓捆绑图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!