Simples Assim

How to Add Menu Items in BlackBerry OS 3.6+

leave a comment »

package br.eti.fernandoribeiro.sample.ui;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.Menu;

import br.eti.fernandoribeiro.sample.util.SampleResource;

public final class SampleScreen extends MainScreen { // Or other subclass of Screen
  private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(SampleResource.BUNDLE_ID, SampleResource.BUNDLE_NAME);

  protected void makeMenu(final Menu menu, final int instance) {

    if (Menu.INSTANCE_DEFAULT == instance) { // Or Menu.INSTANCE_CONTEXT or Menu.INSTANCE_CONTEXT_SELECTION
      final MenuItem miItem = new MenuItem(BUNDLE.getString(SampleResource.MENUITEM_TEST), 0, 0) {

        public void run() {
          ...
        }

	  };

      add(miItem);

      add(MenuItem.separator(1));

      final MenuItem miItem2 = new MenuItem(BUNDLE.getString(SampleResource.MENUITEM_TEST), 2, 0) {

        public void run() {
          ...
        }

	  };

      add(miItem2);
	}

  }

}

Advertisement

Written by Fernando Ribeiro

July 18, 2010 at 9:09 pm

Posted in Software

Tagged with

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 )

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

Follow

Get every new post delivered to your Inbox.

Join 781 other followers