Adding Menu Items To A Blackberry Device Application; Register A Menu Item - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Development Guide
new ContactsDemo().enterEventDispatcher();
} else {
throw new IllegalStateException( "Context is null, expected a Contact
instance");
}
return null;
}

Adding menu items to a BlackBerry device application

You can use the Application Menu Item API, in the net.rim.blackberry.api.menuitem package to add menu
items to a BlackBerry® device application. You can use the ApplicationMenuItemRepository class to add or remove
menu items from a BlackBerry device application.

Register a menu item

1.
Import the following classes:
• net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository
• net.rim.device.api.ui.MenuItem
2.
Create a class that extends the MenuItem class.
ContactsDemoMenuItem contactsDemoMenuItem = new ContactsDemoMenuItem();
3.
Invoke ApplicationMenuItemRepository.getInstance to retrieve the BlackBerry® device application
repository.
ApplicationMenuItemRepository repository =
ApplicationMenuItemRepository.getInstance();
4.
Create an instance of the class that extends the MenuItem class.
ContactsDemoMenuItem contactsDemoMenuItem = new ContactsDemoMenuItem();
5.
Invoke ApplicationMenuItemRepository.addMenuItem() to add the custom menu item to the
BlackBerry device application repository.
repository.addMenuItem
(ApplicationMenuItemRepository.MENUITEM_ADDRESSCARD_VIEW,
contactsDemoMenuItem);
6.
Invoke ApplicationMenuItemRepository.addMenuItem(). Use the MENUITEM_MAPS field to add
the menu item to the BlackBerry device application.
repository.addMenuItem(ApplicationMenuItemRepository.MENUITEM_MAPS,
contactsDemoMenuItem);
28

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment

Table of Contents