1
Adding custom menu items to applications
Adding menu items to BlackBerry Java Applications
The Application Menu Item API, in the
net.rim.blackberry.api.menuitem
package, lets you add menu items
to BlackBerry® Java® Applications. The
ApplicationMenuItemRepository
class lets you add or remove menu
items from BlackBerry Java Applications.
Create a menu item
Adding menu items to BlackBerry Java Applications
Task
Steps
Define a menu item.
>
Extend the abstract
ApplicationMenuItem
class.
public class SampleMenuItem extends ApplicationMenuItem { ... }
Specify the position of the menu
item in the menu.
A higher number means that the menu item appears lower in the menu.
>
Invoke
ApplicationMenuItem()
SampleMenuItem() {
super(20);
}
Specify the menu item text.
>
Implement
toString()
.
public String toString() {
return "Open the Contacts Demo application";
}
Specify the behaviour of the menu
item.
>
Implement
run()
.
public Object run(Object context) {
Contact c = (Contact)context; // An error occurs if this does not work.
if ( c != null ) {
new ContactsDemo().enterEventDispatcher();
} else {
throw new IllegalStateException( "Context is null, expected a Contact
instance");
}
Dialog.alert("Viewing a message in the messaging view");
return null;
}
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Page 4: ......
Page 7: ......
Page 10: ...10 BlackBerry Device Applications Integration Guide...
Page 12: ...12 BlackBerry Device Applications Integration Guide...
Page 50: ...50 BlackBerry Device Applications Integration Guide...
Page 56: ...56 BlackBerry Device Applications Integration Guide...
Page 65: ......
Page 66: ...2008 Research In Motion Limited Published in Canada...