Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Go back to previous screen

To amplify a bit on mantaker's responses.

 

The display stack is the stack of screens you have pushed.  Let us say you have these screens in your applications:

 

A - Home Screen - this is the initial screen you start with and it displays a list of the current items

B - Options Screen - this displays options for the application

C - Detail screen - this displays details for the item the user has selected from Screen A.

 

Now say your user is in the Home Screen,  they have one screen on the stack. 

 

Then they select Options from the Menu, in the menu processing you push the Options screen.  Now you have two screens on the stack, the Options Screen and under it the Home Screen.  Once the user has changed any options they wish to change they will 'save' and in the save processing, you will pop the Options screen.  Now the Home Screen, which was there all the time but hidden, is displayed.

 

Now they select an item and use the Menu to get Details for that item, in your menu processing you push the Detail screen.  On the stack now they have 2 screens, the Home Screen and the Detail Screen. Once they have finished with the Detail screen, they will press ESC or use the Close menu item you have provided.  This processing will pop the Detail Screen and the Home screen is displayed again.

 

Does this make sense.  Do you see how push and pop work for screens now?

Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

I agree with peter, this is how you should design your application rather making it clumsy..
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: How to Go back to previous screen

Peter and 'Mantaker'

Thanx for this guidence....:smileyhappy:

 

I understand this what u described...

 

But truly says I made my app little clumpsy because  I am calling number of Sub Screens from my MENU in application and after going

thru these MENU Sub Screens I m again calling HOME screen .....

 

I think doing in this way my Sub Screens are still there in display stack UNDER Home Screen

 

Now I will try to follow ur steps.

 

Thnx to u...

 

 

 

Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

If you really want to thank us, please mark this thread with a solution.. :smileytongue:

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009
My Device: Not Specified

Re: How to Go back to previous screen

[ Edited ]

If you have the same example, a Home screen, and a subscreen that processes data as it lays itself out and paints itself, and you want to go back to the HomeScreen, can you do

 

UiApplication.getUiApplication().pushScreen(getScreenBelow));

 

I got a RuntimeException when I tried to do this. Before I was creating a new Instance of the home screen, which is probably really poor implementation:

 

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

 

EDIT:

 

Also, where do you ovveride this? in onClose()? The default close() method doesn't pop the screen?

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Go back to previous screen

This is a solved Thread, if you have a new question best to ask it in a new Thread.

 

UiApplication.getUiApplication().pushScreen(getScr eenBelow)); will never work.  The Screen is already on the Display stack.  You are asking it to be in two places on the Display Stack.  If it is the screen below, then popping the current screen will display it. 

 

I thought the default close() did in fact pop the screen.  I usually override it so I'm not 100% sure but that is what I thought.  Certainly for MainScreen I'm pretty sure.

Developer
weaselgrater
Posts: 87
Registered: ‎08-25-2009
My Device: Not Specified

Re: How to Go back to previous screen

[ Edited ]

Can I make a screen a singleton? and then push it, even if its already on the stack somewhere? Do you pop the mainscreen before pushing another?

 

Here is what I mean

A -> B -> C

A -> B

A <- B

 

When I go from A to B, I push B. When I go from B to C, I push C. When I leave C, I pop it. but when I leave B, I do not want to pop it, nor do I want to push a new A(). so can I push(A.getInstance())

 

Or do I have to pop A when I push B in order to keep B running and go back to A?

 

Sorry I'll start a new Thread.

 

 

New Contributor
hoshang09
Posts: 2
Registered: ‎02-09-2011
My Device: Not Specified

Re: How to Go back to previous screen

The above solution is not working for me. I have an app which has 3 Java files in the same package

 

 

  • HelloWorldApp.java: This extends UiApplication class and launches the FirstScreen using pushScreen() method
  • FirstScreen.java: It has a button which pushes screen named SecondScreen
  • SecondScreen.java: It has a button which is named "Go Back".

 

FirstScreen.java and SecondScreen.java implement FieldChangeLIstener  interface and extend MainScreen class.

 

I have used UiApplication.getUiApplication().popScreen(this); in SecondScreen.java to go back to First Screen. But it isn't working. What am i doing wrong?

 

Help asap please!

Thanks

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Go back to previous screen

As this is a Solved Thread, you are better raising this as a new problem on a new Thread.  However when you do, please can you be a little more explicit that 'it isn't working.  Can you describe exactly what you do, what you see and what you expect to see.  Some code snippets might be useful too.