views:

261

answers:

4

Hello All...

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....

+4  A: 

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.

ageektrapped
@ageektrapped Thanks... It works for me..
Nirmal
A: 

I have the exact same problem, but the solution above didn't work for me. Any suggestions?

Hesham Abd-Elmegid
try to debug your code , but probably above solution should work which was changed in latest blackberry plugin.Just put image in resource folder and use getBitmapResource("name_of_image")
Burak Dede
A: 

thanks a lot..above solution worked!!

Pals
A: 

yeah, it worked... thanks (the exact name show in the inside jar (.zip) must be copied in the code u_u)

Isabel