When a button is pressed on Screen A, I push Screen B. And when Bac开发者_开发知识库k button is pressed on Screen B, I want Screen A to understand that to update Screen. Is there any way to handle this?
When Screen B is popped, it will have its onUiEngineAttached(boolean) function called, with the parameter set to false. If Screen B held a reference to Screen A, it could then trigger whatever updating is needed.
Another way is to setup your own Listener where Screen B would provide the event and Screen A would listen for the event. Again, you would probably fire the event from the onUiEngineAttached(boolean) function.
You could use a callback pattern. Check my another post for details. Upon any UI event on your Screen B (e.g. a button is pressed) the Screen B runs the callback passing any parameter if needed. Going this way your Screen A keeps its original/clean interface.
You can detect the device 'Back' btn press with this code:
protected boolean keyChar(char c, int status, int time) {
if (c == Characters.ESCAPE) {
// .. run callback here ..
close(); // actually close the Screen B
return true;
}
return super.keyChar(c, status, time);
}
Screen B is popped off of the stack, so it will get the onUiEngineAttached() callback. But you are interested in screen A, which will get a different callback - Screen.onExposed().
I think this can be done using YUI History manager.
精彩评论