开发者

Trying to draw a bitmap on blackberry

开发者 https://www.devze.com 2023-03-03 06:28 出处:网络
I\'m just learing how to program the blackberry and trying to display a bitmap on the screen, here is the code:

I'm just learing how to program the blackberry and trying to display a bitmap on the screen, here is the code:

public MyScreen()
{        
    // Set the displayed title of the screen       
    setTitle("MyTitle2");
    LabelField lb = new LabelField("hello ted2");
    add(lb);开发者_StackOverflow社区

    Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
    BitmapField fd= new BitmapField(logoBitmap, Field.FIELD_HCENTER);
    add(fd); 
}

The label is drawn but not the bitmap.


Your path is wrong, copy the image into /res/img. To retrieve that, use the file name only.

Bitmap logoBitmap = Bitmap.getBitmapResource("icon2.png");


I think you need to put the two fields into a VerticalFieldManager:

public MyScreen()
{        
    VerticalFieldManager vfm = new VerticalFieldManager();

    // Set the displayed title of the screen       
    setTitle("MyTitle2");
    LabelField lb = new LabelField("hello ted2");
    vfm.add(lb);

    Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
    BitmapField fd= new BitmapField(logoBitmap);
    vfm.add(fd); 

    add(vfm);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消