BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 04-28-2010, 05:00 AM   #1
karthikus
New Member
 
Join Date: Apr 2010
Model: 9630
PIN: N/A
Carrier: airtel
Posts: 8
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


Code:
public class ContactMain extends UiApplication {

	public static void main(String[] args) {

		ContactMain contactMain = new ContactMain();
		contactMain.enterEventDispatcher();
	}

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

}


--------------------------


final class ContactMainScreen extends MainScreen {

	//components declaration


	public ContactMainScreen() {

          //initialize components

	}

	protected void makeMenu(Menu menu, int instance) {
		menu.add(addContact);
		
	}

	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 05:08 AM..
Offline  
Old 04-28-2010, 08:20 AM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

This:

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

Should be:

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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


6802 II Digital Thermocouple Thermometer Dual Channel 2*K-Type Temperature Meter picture

6802 II Digital Thermocouple Thermometer Dual Channel 2*K-Type Temperature Meter

$24.40



Digital Thermometer Dual Channel Input Thermocouple K J T E R N C/F Selection US picture

Digital Thermometer Dual Channel Input Thermocouple K J T E R N C/F Selection US

$25.99



K Type Temperature Sensor Probe 1.5M Cable 4mmx100mm Probe Thermocouple picture

K Type Temperature Sensor Probe 1.5M Cable 4mmx100mm Probe Thermocouple

$17.87



Robertshaw Thermocouple 48

Robertshaw Thermocouple 48" 1980-048 Snap Fit Universal (51-1457)

$15.89



K Type Thermocouple Stainless Steel Temperature Sensors Thermocouple 1 Pcs picture

K Type Thermocouple Stainless Steel Temperature Sensors Thermocouple 1 Pcs

$17.15



K-Type Thermocouple Wire 2 Core AWG 24 High Temperature PTFE Insulation 6.6ft picture

K-Type Thermocouple Wire 2 Core AWG 24 High Temperature PTFE Insulation 6.6ft

$13.48







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.