Dynamic Menus

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Dynamic Menus

Postby stilwalli » Wed Sep 24, 2008 5:52 am

Is there any way to add menus dynamically?
stilwalli
Developer
Developer
 
Posts: 35
Joined: Mon Jul 21, 2008 8:13 am

Top

Postby plusminus » Wed Sep 24, 2008 1:13 pm

You mean in your application :?:

You can do sth like [font=Courier New]setVisibile(false)[/font] in [font=Courier New]onPrepareOptionsMenu[/font]

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby MrSnowflake » Thu Oct 02, 2008 2:14 pm

You could maintain a list of MenuItem object as a field of your activity and add item to this. Then in onCreateMenu (or onPrepare, don't know exactly), use this list to add the MenuItem to the menu.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby andreagosto » Fri Oct 03, 2008 8:59 am

you can also add dynamically item in menu. in onCreateOptionsMenu(Menu menu) you have to assign the parameter menu passed to a class variable, (sorry for english, in this way: mMenu = menu; ). Then, you'll can interact with menu when you'll like (and where you'll like) in normal way.
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 12 guests