Blackberry: how to show menu in Screen extends FullScreen

In Blackberry platform, for any application development if you need to add menu items on the screen that extends from FullScreen, then you may use the following code sample:

For example,  there is a Screen extended from FullScreen with Close MenuItem to show if clicked on menu button of blackberry mobile phone-


import net.rim.device.api.ui.container.FullScreen;
...
public class LoginScreen extends FullScreen
{
	//Constructors
	public LoginScreen()
	{
		//other stuff
	}
	private MenuItem _closeMenuItm  = new MenuItem("Close",40,40)
	{
		public void run()
		{
			close();
		}
	};
	//overrides
	public boolean onMenu(int instance)
	{
		//to show menu items
		getMenu(instance).show();
		//
		return true;
	}
	//overrides
	protected void makeMenu(Menu menu,int instance)
	{
		menu.deleteAll();
		menu.add(_closeMenuItm);
		//set position to show in screen
		menu.setOrigin(-10, Display.getHeight()+15);
		//
		super.makeMenu(menu, instance);
	}
	/*** @see net.rim.device.api.ui.Screen#close()
	 */
	//overrides
	public void close()
	{
		int response = Dialog.ask(Dialog.D_YES_NO,"Are you sure to exit?",Dialog.NO);
		if(response == Dialog.YES)
		{
			System.exit(0);
			super.close();
		}
	}//end of class
}
}



Advertisements

About M Moniruzzaman
A passionate software engineer, have been developing applications on various platforms such as Android, iPhone, .Net (C#) technologies and web based ASP.NET, PHP, JavaScript, jQuery technologies for more than 10 years. Especially I have expertise on developing applications for Android and iPhone, as well as service oriented, client-server based applications where clients will be reside on Android/iPhone that communicate with WCF(.NET) service hosted on server. I have completed certification in Microsoft Certified Professional Developer (MCPD) on .Net 4 . I have completed my graduation in -- B.Sc. (Engineering) in Computer Science and Engineering, ShahJalal University of Science and Technology, Bangladesh. Thanks, M. Moniruzzaman (Zaman)

5 Responses to Blackberry: how to show menu in Screen extends FullScreen

  1. Mohammed Ali says:

    helpful, Thanks 🙂

  2. Onni Zmakaj says:

    How to use this ?/

  3. monmomo04 says:

    Thanks. The sample is : clear, short, very instructive and helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: