Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer

Override the default menu items of blackberry

Hi,

 

I am trying to override the default menu items of blackberry. like close, back

 

I am using following code to remove the default menu items:-

if (blackberry.ui.menu.getMenuItems().length > 0) {
          blackberry.ui.menu.clearMenuItems();
}

 

Now i add the new menu items.

 

Newly added menu items can be seen in the menu, but default menu items are still coming. Is there any other way to override or delete them.

 

I have tried building my solution from bot SDK 2.1 and eclipse plugin. Nothing worked. Please help.

Thanks

Developer
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: Override the default menu items of blackberry

Hello joygupta,

 

You could go see this thread for a similar scenario but I found  

 

Hope this helps. Smiley Wink

Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer

Re: Override the default menu items of blackberry

Hi jdnoprada,

 

Thanks for the suggestion. Actually my app need to overide close menu as it is a functional requirement.

 

And i am not able to delete close menu item.I have already seen both the examples and

 

ClearMenuItem does not delete the close menu.

 

thanks,

Joy

Trusted Contributor
Posts: 145
Registered: ‎05-01-2011
My Device: 9780
My Carrier: Developer

Re: Override the default menu items of blackberry

[ Edited ]

protected void makeMenu(final Menu menu, final int instance) {
        final MenuItem add = new MenuItem("Custom Added 1", 50, 8) {
            public void run() {
                // Processing
            }
        };
        final MenuItem add2 = new MenuItem("Custom Added 2", 50, 8) {
            public void run() {
                // Processing
            }
        };
        final MenuItem add3 = new MenuItem("Custom Added 3", 50, 8) {
            public void run() {
                // Processing
            }
        };
        menu.deleteAll();
        menu.add(add);
        menu.add(add2);
        menu.add(add3);
    }