Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Guide de dépannage Page 36

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 286
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 35
36
BlackBerry Java Development Environment Development Guide
Adding menu items to BlackBerry applications
The Application Menu Item API, in the net.rim.blackberry.api.menuitem package, lets you add menu items
to BlackBerry® applications. The
ApplicationMenuItemRepository class lets you add or remove menu items
from BlackBerry applications.
Create a menu item
Register a menu item
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 behavior 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;
}
Task Steps
Retrieve the application menu item
repository.
>Invoke ApplicationMenuItemRepository.getInstance().
ApplicationMenuItemRepository repository =
ApplicationMenuItemRepository.getInstance();
Create your application menu item. > Invoke the constructor.
TestApplicationMenuItem tami = new TestApplicationMenuItem();
Add the menu item to the repository. >Invoke addMenuItem().
repository.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSC
ARD_VIEW, tami);
Vue de la page 35
1 2 ... 31 32 33 34 35 36 37 38 39 40 41 ... 285 286

Commentaires sur ces manuels

Pas de commentaire