Inability to display image in Blackberry Simulator
I just started learning the basics of Blackberry ....
So, I ran into one issue in the Blackberry Bitmap UI.
I have a UiFunApplication class that has a 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 has the 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 also included image.png in the res folder, which is in the same directory structure as src.
Back in the simulator, I just get a shortcut called "Hello World" but not the image at the top.
Thanks in advance....
a source to share
The latest BlackBerry plugin in Eclipse uses the res folder convention from J2ME: everything in the res folder ends with the 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 see if this is the problem, look in the results folder in the project directory for the jar generated by Eclipse. Open it (just rename the extension to .zip) and make sure the image is right at the top level of the jar.
If you want res to be there, add another res folder to the res folder and put all your images there.
a source to share