03-09-2011 04:11 PM
What is the difference between pushscreen and popscreen?
I am trying to make the flow of screen using this piece of code to pass to next screen,
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
UiApplication.getUiApplication().pushScreen(nextSc reen);
}
});
but I noted previous screen is still opened even if nextScreen is pushed.
What should be right way to swich screens?
Solved! Go to Solution.
03-09-2011 04:27 PM
Displayed Screens in BlackBerry UI Applications are kept in a stack, called Screen stack. The top of the stack is so called "active Screen" - the only Screen which can get user's input. Screens which are closer to the top obscure those deeper down.
pushScreen puts a (previously undisplayed - otherwise it will throw an exception) Screen on top of the Screen stack, which makes it active. popScreen removes the activeScreen (if no parameters are given - this functionality is deprecated) or the specified Screen (if displayed - again, will throw an exception otherwise) from the Screen stack. If the top (active) Screen is popped, the one below it becomes the top one - accepting user's input and unobscured.
That's it! Design your application the way you see fit, but with this picture in mind.
03-09-2011 04:39 PM
With pushScreen() you'll push a Screen into the stack. If you pop a Screen, you're removing it from the stack.
I think your problem is that can't push a Screen in top of the others if you don't pop it before.
03-09-2011 05:13 PM
I'm not sure if I read Astarot's post correctly -- it's been a long week already -- but want to make sure that it's clear that you can push more than one screen onto the stack (i.e., you don't have to pop a screen before you push another screen). Are you getting any Exceptions when you try to push the screen? Also, could you possibly post a little more code, like what is making this call just in case the bug is actually in another part of the program.