BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 04-28-2010, 06:00 AM   #1 (permalink)
New Member
Join Date: Apr 2010
Model: 9630
Carrier: airtel
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Push a new screen on a menu item select - Beginner help

Please Login to Remove!

Guys i am very new to the world of blackberry. I have one question now. I have created a small application where i will have a MAIN screen displaying some components. But when the user presses the menu and select a menu option i need to push another screen containing different set of components.My sample code is as follows

public class ContactMain extends UiApplication {

	public static void main(String[] args) {

		ContactMain contactMain = new ContactMain();

	public ContactMain() {
		pushScreen(new ContactMainScreen());



final class ContactMainScreen extends MainScreen {

	//components declaration

	public ContactMainScreen() {

          //initialize components


	protected void makeMenu(Menu menu, int instance) {

	private MenuItem addContact = new MenuItem("Add Contact", 110, 10)                      
		public void run() {
			UiApplication.getUiApplication().(new ContactAddScreen());



final class ContactAddScreen extends MainScreen {

	//components declaration

	public ContactAddScreen() {

		    //initialize components


But as soon as i press the menu i am getting a null pointer exception .

please help

Last edited by karthikus : 04-28-2010 at 06:08 AM.
Old 04-28-2010, 09:20 AM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts


UiApplication.getUiApplication().(new ContactAddScreen());

Should be:

UiApplication.getUiApplication().pushScreen(new ContactAddScreen());
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Copyright 2004-2014
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.