12-30-2008 06:21 AM
Hi.
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)
Solved! Go to Solution.
12-30-2008 08:28 AM
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?
01-22-2009 08:36 AM
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 ![]()
Thank you for your input and interest.
07-06-2009 04:50 AM
07-06-2009 07:15 AM
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.
08-26-2009 09:28 AM
Hi,
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!