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: 950
Registered: ‎06-22-2010
My Device: 9550
Accepted Solution

Open a screen from Another Screen.

Hello Guys,

Plz tell me that,

How can i call a another screen form One screen On clicking a Button.

Developer
Posts: 16,510
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Open a screen from Another Screen.

you display a screen using UiApplication.getUiApplication().pushScreen(newScreen)

you can create a button using CONSUME_CLICK and react using a fieldchangelistener, or you can handle navigationclick etc.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

Re: Open a screen from Another Screen.

And since you are a beginner, here's a sample code of what Simon described above (not compiled or tested but should give you an idea)

 

 

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class FirstScreen extends MainScreen implements FieldChangeListener {
	ButtonField theButton;

	public FirstScreen() {
		add(new LabelField("First Screen"));

		theButton = new ButtonField("New Screen", ButtonField.CONSUME_CLICK);

		theButton.setChangeListener(this);

		add(theButton);
	}

	public void fieldChanged(Field field, int context) {

		if (field == theButton) {
		UiApplication.getUiApplication().pushScreen(new SecondScreen());
		}

	}

	public class SecondScreen extends MainScreen {

		public SecondScreen() {
			add(new LabelField("Second Screen"));
		}
	}
}

 

 

 

 

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: Open a screen from Another Screen.

Thank u TobiasReaper,

My Problem is Solved.

Developer
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

Re: Open a screen from Another Screen.

Glad to be of assistance mate. Enjoy coding. :smileyhappy:

New Contributor
Posts: 2
Registered: ‎04-16-2010
My Device: 9000, 8900, 9630

Re: Open a screen from Another Screen.

Perfect, thanks for the code example!

Trusted Contributor
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: Open a screen from Another Screen.

thanks i use ur code and i solve my problem 

 and i also click on kudo of u

Contributor
Posts: 42
Registered: ‎10-23-2011
My Device: curve 8520

Re: Open a screen from Another Screen.

Hello Sir ,

I came accross your code and tried to run it on the 9900 simulator and for some reason it doesnt pick up the code. as in the application does not appear on the main menu screen so i can not launch it at all.

 

 

do you no why.. id really appriciate the help

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

Re: Open a screen from Another Screen.

As previously suggested, don't post on Solved Threads, start you own Thread.  And can I also suggest that you don't make multiple posts for the same problem. 

 

As far as I can tell, your problem has been solved too:

http://supportforums.blackberry.com/t5/Java-Development/APPLICATION-will-not-appear-on-main-menu-of-...