我不知道如何使用java在黑莓中点击按钮时显示另一个页面。
答案 0 :(得分:2)
我假设您已将ButtonField添加到某种屏幕。您需要为ButtonField设置FieldChangeListener:
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);
}
}
另请注意,您需要在推送屏幕之前获取事件锁定,或者将UiApplication.invokeLater传递给Runnable,如下所示:
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(new FullScreen());
}
});
BB上有关UI线程问题的一些基础知识:http://www.thinkingblackberry.com/archives/182
答案 1 :(得分:1)
UiApplication.getUiApplication.pushScreen(new Screen());
http://www.blackberry.com/developers/docs/4.5.0api/index.html