开发者

Open a MainScreen from another MainScreen

开发者 https://www.devze.com 2023-02-14 02:24 出处:网络
In my app, I want to open a MainScreen from another MainScreen. How can I do this? From UiApplication I can use pushScreen(Screen) to go to a MainScreen. But when I try the same from a MainScreen开发

In my app, I want to open a MainScreen from another MainScreen. How can I do this?

From UiApplication I can use pushScreen(Screen) to go to a MainScreen. But when I try the same from a MainScreen开发者_JS百科 I get a JVM error 104.


Ui.getUiEngine().pushScreen(Screen);


So let's say you have Screen2 extends MainScreen.


Screen2 s2 = new Screen2(); 
UiApplication.getUIApplication.pushScreen(s2); 

Note that the code above must be executed from within the main Ui event thread. If you're displaying the screen in response to an UI event, this is the default. However, if you're pushing the screen from a background thread, you'll need to marshall the call onto the event thread as follows:

UiApplication.getUiApplication().invokeLater( new Runnable() { 
    public void run() { 
     Screen2 s2 = new Screen2(); 
     UiApplication.getUIApplication.pushScreen(s2); 
    }
});
0

精彩评论

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

关注公众号