Adding custom menu items to applications
Adding menu items to BlackBerry Java Applications
Adding menu items to BlackBerry Java Applications
The Application Menu Item API, in the
to BlackBerry® Java® Applications. The
items from BlackBerry Java Applications.
Create a menu item
Task
Define a menu item.
Specify the position of the menu
item in the menu.
Specify the menu item text.
Specify the behaviour of the menu
item.
net.rim.blackberry.api.menuitem
ApplicationMenuItemRepository
Steps
ApplicationMenuItem
>
Extend the abstract
public class SampleMenuItem extends ApplicationMenuItem { ... }
A higher number means that the menu item appears lower in the menu.
ApplicationMenuItem()
>
Invoke
SampleMenuItem() {
super(20);
}
toString()
>
Implement
public String toString() {
return "Open the Contacts Demo application";
}
run()
>
Implement
.
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;
}
class lets you add or remove menu
class.
.
package, lets you add menu items
1