如何在 UiApplication 上显示图像?
我有一个显示按钮的代码,单击它时会转到 a MainScreen
,但我想在该按钮下方显示一个图像。我找到了一种插入可缩放图像但不是静态图像的方法。
到目前为止,这是我的代码:
public class HelloWorldDemo extends UiApplication {
private MainScreen _screen;
private ButtonField _nextScreen;
public static void main(String[] args) {
HelloWorldDemo instance = new HelloWorldDemo();
instance.enterEventDispatcher();
}
public HelloWorldDemo() {
EncodedImage myImg = EncodedImage.getEncodedImageResource("k.jpg");
ZoomScreen zoomableImg = new ZoomScreen(myImg);
_screen = new MainScreen();
_nextScreen = new ButtonField("Go to Next Screen",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
_nextScreen.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field,int context) {
pushScreen(new NextScreen());
}
});
_screen.setTitle(new LabelField("Hello World Demo",LabelField.USE_ALL_WIDTH));
_screen.add(new RichTextField("Hello to the BlackBerry World!",Field.NON_FOCUSABLE));
_screen.add(_nextScreen);
pushScreen(_screen);
pushScreen(zoomableImg);
}
}