How do you modify MenuItems?

CidTek

Active Member
Licensed User
Longtime User
I have an activity that depending on user action within a listview I want to show a different menu item. That works fine for the first menu item but I can't change the menu item on subsequent user actions in the listview.

The only way I can get different menu items is if I destroy the activity to start afresh with a new menu.

I need some sort of activity.deletemenu event.
 

CidTek

Active Member
Licensed User
Longtime User
Currently you cannot remove existing menu items. You can either use multiple activities or you can create a custom panel with buttons instead of the menu. You can catch the Menu button and show it instead of the regular menu.

Is menu removal a feature coming in the future?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

warwound

Expert
Licensed User
Longtime User
What would happen if JavaObject was used to call the Activity invalidateOptionsMenu method to clear all MenuItems?
Would you then be able to add new MenuItems?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I would also like to know the answer for this.

You'd see no change at all if you called the java method invalidateOptionsMenu():
  • Calling invalidateOptionsMenu() invalidates the options menu - any currently created options menu is discarded.
  • When the activity next needs to display the options menu, the activity will create a new options menu.
  • The new options menu will be created using all the MenuItems previously added.

So you can force the activity to rebuild it's options menu but unless you can access the 'already added' MenuItems and clear them or remove one or more, then the rebuilt options menu will be identical to the invalidated options menu.

If, from b4a, you could access and modify the already added MenuItems then you could invalidate the options menu, modify the MenuItems and then when the activity rebuilds the options menu it would reflect the modified MenuItems.

Hope i explained that clearly?

Martin.
 
Upvote 0
Top