0

我不知道为什么,但我无法在我的黑莓应用程序中显示 bitmapField。位图从不渲染。

这是代码:图像放在res文件夹中:

package mypackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
    BitmapField bitmapField;

    /**
     * Creates a new MyScreen object
     */
    public MyScreen()
    {        
        Bitmap logoBitmap = Bitmap.getBitmapResource("res/apresslogo.png");
        bitmapField = new BitmapField(logoBitmap,Field.FIELD_HCENTER);
        add(bitmapField); 
        // Set the displayed title of the screen       
        setTitle("MyTitle");
    }
}
4

1 回答 1

2

尝试只传递文件名,而不传递路径:

Bitmap logoBitmap = Bitmap.getBitmapResource("apresslogo.png");
于 2013-05-26T03:49:32.390 回答