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

Java Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

Updating Menu or menu items



I am having trouble changing the behaviour of menu items.

First I create a menu with x menu items.

Later on, on a specific event I want to change a menu item n or(as a fallback) I can recreate the whole menu with a new set of menu items.


What I tried is to use Menu.deleteAll() and Menu.deleteItem(int n) and both fail to remove any menu item.

I then thought, ok, maybe I cannot change already created menu/menu items. Maybe that's only available in makeMenu (although I didn't find any such instructions). But ! if i add a menu item to the same menu (even after the delete methods) the menu item gets on the menu and is correctly displayed.

Maybe we can add but cannot remove existing menu items ?

Now, what is going on?


All I want to do is to change a menuItem caption and its run() method (i.e., replace an existing menuItem).


Anyone has any ideas ?


(I am testing it on jde 4.5, on 8810 simulator)

"Listen carefully, I shall say this only once"
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Updating Menu or menu items

I'm not sure I understand the question, but here goes:


To build menus, I override the makeMenu() method of my screen class. This method is called each and every time the menu key is pressed. Within this makeMenu() method, I place items on the menu (or not) as is appropriate for the application or screen context at the time the menu is created.


Consequently, there is no reason to remove items from a menu, so I have never tried to do so.


So, I guess I need to understand why are you trying to remove menu items?


Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Updating Menu or menu items

Hi, sorry for the late reply, but I have closed the issue, partially.


My app has a lot of states, and in some states, certain menu items should be removed.


As it turns out, it is better to use MainScreen.removeMenuItem rather than Menu.DeleteAll().


The former approach works, the latter one doesn't Smiley Sad


Thank you for your input and interest.

"Listen carefully, I shall say this only once"
New Developer
Posts: 10
Registered: ‎06-18-2009
My Device: Not Specified

Re: Updating Menu or menu items

Can anyone tell me .. how to add a new MENU with 4-5 menu items for a application on BB.?? Also, i want to navigate to a particular screen on click of any menu item.
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Updating Menu or menu items

Something like this... In your MainScreen class. You check with some sample codes shipped with JDE.



protected void makeMenu(Menu menu, int instance) { menu.add(_fetchMenuItem1); menu.add(_fetchMenuItem2); .... menu.add(_fetchMenuItem5); } private MenuItem _fetchMenuItem1 = new MenuItem("Fetch1" , 100, 10) { public void run() { // code here } }; private MenuItem _fetchMenuItem2 = new MenuItem("Fetch2" , 105, 10) { public void run() { // code here } };


 To Navigate from Screen to Sceen, you have to push the Screen to the Display stack using pushScreen method. popScreen method to remove the screen from Display.


There are good number of threads discussed.


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 3
Registered: ‎08-24-2009
My Device: Not Specified

Re: Updating Menu or menu items



I´m really new in BlackBerry development. I crated a special Menu with certain Menu Items.


Now I want to add a icons to the menuItems. If you have a look at the standard Menu (manage connections) then you can see a colored status icon for connection-status(green check mark or red cross).


Please Help, how do I get such icons added to the MenuItems?


kind regards!