Cannot add image to my UI
Here is a screenshot of the solution explorer:
And here is the code I'm using. Note that the RichTextFields do show up, but no picture. I've tried displaying both of the pictures in the res folder but no dice.
final class HelloWorldScreen extends MainScreen {
BitmapField logo开发者_Python百科Field;
public HelloWorldScreen() {
super();
LabelField title = new LabelField("Moxxy Email Sender",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField("1. Where do you want to send this?"));
add(new RichTextField("2. What's your name?"));
add(new RichTextField("3. Write down your message:"));
Bitmap logoImage = Bitmap.getBitmapResource("res/tip.png");
logoField = new BitmapField(logoImage, Field.FIELD_HCENTER);
add(logoField);
}
public boolean onClose() {
Dialog.alert("Goodbye!");
System.exit(0);
return true;
}
}
Try removing "res" from the path in the code, i.e:
Bitmap logoImage = Bitmap.getBitmapResource("tip.png");
精彩评论