【发布时间】:2011-12-19 15:34:28
【问题描述】:
我如何在 java 黑莓模拟器中设置背景图像?
backgroundBitmap = Bitmap.getBitmapResource("background.png");
MainScreen mainScreen = new MainScreen();
HorizontalFieldManager horizontalFieldManager =
new HorizontalFieldManager(
HorizontalFieldManager.USE_ALL_WIDTH |
HorizontalFieldManager.USE_ALL_HEIGHT){
//Override the paint method to draw the background image.
public void paint(Graphics graphics) {
//Draw the background image and then call paint.
graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
【问题讨论】:
-
如果您搜索论坛,您可以找到具有相同信息的各种帖子
-
空指针异常表示代码无法获取png文件。你把文件“background.png”放在哪里了?
-
我将png图片复制到项目的res文件夹中
-
请同时检查文件名的拼写,可能是它的问题
标签: blackberry