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
nitinverma274
Posts: 950
Registered: ‎06-22-2010
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.

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

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
Please use plain text.
Developer
TobiasReaper
Posts: 85
Registered: ‎05-03-2010

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"));
		}
	}
}

 

 

 

 

Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010

Re: Open a screen from Another Screen.

Thank u TobiasReaper,

My Problem is Solved.

Please use plain text.
Developer
TobiasReaper
Posts: 85
Registered: ‎05-03-2010

Re: Open a screen from Another Screen.

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

Please use plain text.
New Contributor
mylestan
Posts: 2
Registered: ‎04-16-2010
My Carrier: Rogers

Re: Open a screen from Another Screen.

Perfect, thanks for the code example!

Please use plain text.
Trusted Contributor
hardikhamar
Posts: 159
Registered: ‎02-17-2011

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

Please use plain text.
Contributor
georgiezzzy
Posts: 42
Registered: ‎10-23-2011
My Carrier: george najem

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

Please use plain text.
Developer
peter_strange
Posts: 19,515
Registered: ‎07-14-2008

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-...

Please use plain text.