Bloodshot
Bloodshot

Reputation: 62

BlackBerry OS 6 Native Menu

Hi I am trying to create a global class for my Native Menu, but can seem to get it to load in my Screen Class, I want this to show up where ever I would like to show up.

Not sure if I am doing it right

Here is my MenuItems Class

public final class MenuItems extends MainScreen {

public void getMenuItems(){
    MenuItem myItem = new MenuItem(new StringProvider("My Cards"), 0x230000, 0);
    myItem.setCommandContext(new Object(){
        public String toString(){
            return "My Cards"; 
        }          
    });

    myItem.setCommand(new Command(new CommandHandler(){         
        public void execute(ReadOnlyCommandMetadata metadata, Object context){
            // Do Something
        }           
    }));

    addMenuItem(myItem);
}
}

The Screen Class I want to add it to is this, not sure if how I would call it here, I tried creating a new instance and just fetching the get method, but no luck, but if I dump the code from the above class in to this class, it will work fine, but I don't want that.

public final class MobiScreen extends MainScreen {
    ToolBar toolbar = new ToolBar();
    Banner banner = new Banner("Welcome");
    MenuItems myMenu = new MenuItems();

    public MobiScreen()
    {        
        setTitle(toolbar.getToolBar());
        setBanner(banner.getBanner());
        myMenu.getMenuItems();
    }
}

Upvotes: 0

Views: 273

Answers (1)

Scott W
Scott W

Reputation: 9872

Why not have MobiScreen extend your MenuItems class?

public class MobiScreen extends MenuItems { ... }

Upvotes: 3

Related Questions