blackberry - instantiate a MenuItem -


i have following problem blackberry demo class:

menuitem locatoritem = new menuitem(new stringprovider("location search"), 0x230020, 0);             locatoritem.setcommand(new command(new commandhandler()              (...) 

i using eclipse , blackberry simulator demo running , 'cannot instantiate type menuitem' error. don't know why , there's no suggestion solve it. imported 'net.rim.device.api.ui.menuitem;'.

i think you're using wrong type of menuitem. net.rim.device.api.ui.menuitem using specific blackberry.

if j2me application/midlet, create javax.microedition.lcdui.command. turned menu items on blackberry.

if you're usingnet.rim.device.api.ui.screen or other net.rim classes in application, way menu items created:

function dosomething() {    // code here }  // in function building screen menuitem somethingmi = new menuitem() {   private menuitem() { super("do something",100001, 5); }    public void run() { dosomething() }; }  addmenuitem(somethingmi); 

Comments