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
New Developer
Posts: 12
Registered: ‎07-08-2009
My Device: Not Specified
Accepted Solution

Second pushed screen doesnt show

Hi everybody, I'm new to blackberry development, and I'm trying to display a login screen on top of a main application screen, they both extend MainScreen.

 

Here is some of my code

public class AppMainScreen extends MainScreen { public AppMainScreen() { setTitle("Title"); showLoginScreen(); } private void showLoginScreen() { UiManager.getInstance().showScreen(new LoginScreen()); } }

 

 

 

public class LoginScreen extends MainScreen { public LoginScreen() { super(); setTitle("Login"); initComponents(); } private void initComponents() { //some components } //More methods }

 

public class UiManager { private static UiManager singleton; private UiManager() { } public static UiManager getInstance() { if (singleton == null) singleton = new UiManager(); return singleton; } public void showScreen(Screen screen) { UiApplication.getUiApplication().pushScreen(screen); } }

I use the UiManager to push both of my screens, but only the main one is shown, what am I doing wrong?

 

Thanks

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: Second pushed screen doesnt show

Do you get any error messages? Try wrapping it in a runnable object or synchronizing on the EventLock.
New Developer
Posts: 12
Registered: ‎07-08-2009
My Device: Not Specified

Re: Second pushed screen doesnt show

I don't get any error messages. I tried synchronizing it on the EventLock but it didn't work I tried wrapping it with a Runnable object and now I get an IllegalStateException
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: Second pushed screen doesnt show

[ Edited ]
The issue might be that  you are trying to push a screen from within the constructor of another screen. Try using a thread to wait until the first screen has been created and then push the second screen immediately after.
Message Edited by CMY on 07-08-2009 05:15 PM
Developer
Posts: 113
Registered: ‎04-09-2009
My Device: Not Specified

Re: Second pushed screen doesnt show

[ Edited ]

Wero_Shinoda,

    Are you trying to display AppMainScreen first and on top of that, you want the LoginScreen to appear? If so, I am not sure whether you can display multiple screen at any point of time.

 

- If you want to display AppMainScreen and soon after you want to display LoginScreen, you need to popup the current screen and push the next screen you want to display.

 

 

 Regards,

-DK

Message Edited by dkumar on 07-08-2009 04:43 PM
New Developer
Posts: 12
Registered: ‎07-08-2009
My Device: Not Specified

Re: Second pushed screen doesnt show

Thank you guys, it finally worked!

 

I took out the pushing of the second screen off the constructor and that seemed to do the trick =)

 

Thank you for your help!