Android Question Activity.AddMenuItem - set conditionally each time the activity is resumed

PHB2

Member
Licensed User
Longtime User
So, I would like to have different activity menu items each time I go into the activity depending on certain criteria.

What seems to happen though, is that the menu items get set correctly the first time in, but subsequent calls to the activity (where the menu items may need to be different) are just ignored, and the activity menu has the original items on it.

My code below is currently in Activity_Resume, as of course Activity_Create only gets called once:
B4X:
If( condition1 = True ) Then
    Activity.AddMenuItem("Add new", "MenuItem_AddNewExercise")
End If
 
If( condition2 = True ) Then
    Activity.AddMenuItem("Add from exercise list", "MenuItem_AddFromExerciseList")
    Activity.AddMenuItem("Add from existing session/routine...", "MenuItem_AddFromList")
End If

How do I use the Activity menu system to allow me to add and remove menu items each time I come into Activity_Resume?

If that is not possible, can I make use of StdActionBar to provide context menu items that look the same as the Activity menu? - I am currently using this for a clean activity bar with a <- button.
 

DonManfred

Expert
Licensed User
Longtime User
Search appcompat Tutorial about changeable menus
 
Upvote 0
Top