Question

I have just started to learn the basics of Blackberry....

So, I am facing one issue in Bitmap UI API of Blackberry..

I have a class called UiFunApplication which have main method :

public class UiFunApplication extends UiApplication {
    public UiFunApplication() {
        UiFunMainScreen mainScreen = new UiFunMainScreen();
        pushScreen(mainScreen);
    }

    public static void main(String[] args) {
        UiFunApplication app = new UiFunApplication();
        app.enterEventDispatcher();
    }
}

Now my UiMainScreen Class have following code :

public class UiFunMainScreen extends MainScreen {

    BitmapField bitmapField;

    public UiFunMainScreen() {
        Bitmap logoBitmap = Bitmap.getBitmapResource("res/image.png");
        bitmapField = new BitmapField(logoBitmap,Field.FIELD_HCENTER);
        add(bitmapField);

        LabelField labelField = new LabelField("Hello World");
        add(labelField);

    }
}

I have also included image.png in the res folder which is in the same directory structure as src.

Still in the simulator I am just getting the label called "Hello World", but not the image at the top.

Thanks in advance....

Was it helpful?

Solution

The latest BlackBerry plugin in Eclipse uses the res folder convention from J2ME: everything in the res folder ends up top-level in your jar file.

So changing the line

Bitmap logoBitmap = Bitmap.getBitmapResource("res/image.png");

to

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

should fix the problem.

To confirm that this is the issue, look in the deliverables folder in your project directory for the jar generated by Eclipse. Open it up (just rename the extension to .zip) and verify that the image is right there at the top level of the jar.

If you want the res to be there, add another res folder under the res folder and put all your images in there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top