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
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified
Accepted Solution

Working with different screens

Hi All

 

I am working with different screens in my app. 

 

I have a screen with 4 tabs. Each tab on click should display a different screen on the device. But i want to open the instance of each screen only once and then rotate these screens on the display stack to bring the desired screen to the front and push the remaining to the background.

 

But the trouble is that when i try using pushScreen() for a screen that has already been displayed once before, i get an error which says that i am trying to push a screen which is already being displayed. But infact the screen is not the currently active screen?? how can i now bring this screen instance to the fore??

 

can someone tell me how this can be achieved?

 

Thanks

 

 

Highlighted
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Working with different screens

Once you push a screen, you have to pop it before you can push it again.

 

The BB display container is organized like a stack.

 

Now, if you have a reference to the screen, you can pop it from anywhere on the stack, then push it again to redisplay.

 

 

Developer
Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: Working with different screens

You may also use a system with one screen containing your 4 tabs and one Manager.

 

Instead of pushScreen you just replace the manager by another, which contains everything you need to display.

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: Working with different screens

Hi Hithredin

 

Can you tell me how i can replace multiple managers in one screen?

 

Thanks!

Developer
Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: Working with different screens

http://www.blackberry.com/developers/docs/5.0.0api/index.html

 

For Screeen objects you have functions

replace(Field oldField, Field newField)

delete(Field field)

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

Re: Working with different screens

I would recommend having a 'manager' per screen, so that you swap just one Manager - this will reduce the overhead.

 

That said, when I have 'tabbed' screens, I typically have multiple screens rather than attempting to manage multiple managers.  I just find this easier.  For example, using the multiple screen approach, you can then have the 'tab bar' permanently set to the screen and you don't have t change it.

Developer
Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: Working with different screens

I also preferred the Peter's solution before.

 

But since OS 6 you have to think with a manager system if you want to use the PaneManager.

By this way I have only a few lines of code to switch from a classic tabbar system with OS < 6.0 to a Pane System with OS6.

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: Working with different screens

Hi All

 

I have used the push and pop screen method as i was really pressed for time and i was comfortable doing the same. But i feel that the manager option is the better option which i want to use in future. So in this case both solutions tie out but i cant mark both as the accepted solution Smiley Sad

 

So i have accepted the manager option as the solution while giving kudos to the screen push-pop solution hope that makes everyone happy! Smiley Happy