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

Java Development

Reply
Contributor
blangszutan
Posts: 14
Registered: ‎02-17-2011
My Carrier: -
Accepted Solution

Retrieve ApplicationMenuItem ID to remove it

Hi all,

this is my first post and i am rather new to Blackberry Java Development...

so in my app:

I've created custom menu and register it with ID MENUITEM_SYSTEM, now i have a problem creating method to remove this custom menu.

I've read in some thread that you have to make sure that the menuitem you want to remove with removeMenuItem(id, menuitem) is the same menuitem that has been created before, so you have to know the id of that menuitem, store it in Runtime or Persistent Store...

My question is, how can i retrieve this menuitem id that i've created before?

is this the same value with the one i get from menuitem.hashCode()?

and if can somehow get the menuitem id, how can i remove it?since the method is removeMenuItem(id, menuitem), and id here represents MENUITEM_SYSTEM, which method should i use to do the job?

 

hope someone can help,

Thx in advance..:smileyhappy:

and sorry for my poor english

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Retrieve ApplicationMenuItem ID to remove it

When you create the menu item, you retain a reference to the instantiated object. This is the value that is passed in the "remove" method.

 

Please use plain text.
Contributor
blangszutan
Posts: 14
Registered: ‎02-17-2011
My Carrier: -

Re: Retrieve ApplicationMenuItem ID to remove it

Yeah i just discovered a way using Runtime Store

when first created, i registered the menuItem to Runtime Store with unique ID,

then, when i want to remove that, simply invoke Runtime Store with the ID registered before, and i get an Object that is, the menuItem.

after that with casting the Object as my menuItem class, i called remove(id, menuItemObject)..voila, the menuItem is removed!

 

So i'll just mark this as solved

Thx though for your explanation

Cheers :smileyhappy:

Please use plain text.