开发者

How to show another page on button click in blackberry using java

I don't know how to show another page on button click in blac开发者_开发技巧kberry using java.


I assume you have a ButtonField added to some kind of Screen. You need to set the FieldChangeListener for the ButtonField:

class YourScreen extends FullScreen {

    public YourScreen() {
        super();
        ButtonField btn = new ButtonField("mybutton");

        btn.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                synchronized (UiApplication.getApplication().getEventLock()) {
                    UiApplication.getUiApplication().pushScreen(new FullScreen());
                }
            }
        });

        add(btn);
    }

}

Also note that you need to either get the event lock before pushing the screen or pass UiApplication.invokeLater a Runnable like so:

UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
        UiApplication.getUiApplication().pushScreen(new FullScreen());
    }
});

Some basics on UI threading issue on BB here: http://www.thinkingblackberry.com/archives/182


UiApplication.getUiApplication.pushScreen(new Screen());

http://www.blackberry.com/developers/docs/4.5.0api/index.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜