*
The moose likes Android and the fly likes Gertting Menu from MenuItem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Gertting Menu from MenuItem" Watch "Gertting Menu from MenuItem" New topic
Author

Gertting Menu from MenuItem

Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
Hello Pals

I want to get the Menu instance from the menu item instance in it. Here is the scenario why i require this

I have created options menu with one item. Now when user clicks this item , i want to add another menu item in the same menu. So i need menu in the call back method from the
MenuItem being passed.

Regards
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Menu Item will have a ID in that. You can use that ID and can create a new menu group by passing that menu id as a group id.
Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
Please find the code and comments below

Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
I will suggest an easier logic. Take a variable which keeps track of you desired menu item's click state. And in onPrepareOptionsMenu or onCreateOptionsMenu you can add or remove other menu item..

I think this should work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Gertting Menu from MenuItem
 
Similar Threads
How to remove menuitem from context menu (SWT)
PrimeFaces dynamic cotextmenu and actions
How to make an Expanding Menu
SWT Question
Navigating menu hierarchy in a JPopupMenu