We may be trying to run before we can walk here!
For the few apps I write for Android I adopt a very clean (in my opinion ) aesthetic using only the main menu on the title bar of an activity. This sort of mimics a desktop app with just a main menu bar. I don't like animations and fancy colored thingies etc. Using the main menu in a B4XPages app means that each page defaults to having the same main menu items and the menu events are raised in Main. I have been trying to customise this for each B4XPage. I have tried adding menu items within each page using this in B4XPage_Create.
but this only works for B4XMainPage as other pages do not seem to have Main as their parent or root. So firstly is there a way to get a reference to Main in every B4XPage so each page can set its own menu items in their own B4XPage_Create?
Having added the menu items I think I can mange to call into each B4XPage as required from the menu event Subs in main. However I now need a mechanism to remove or hide the unwanted items according to which page is displayed. I don't think the menu items can be removed once added but I think they can be individually enabled/disabled and hidden if required. So secondly is there a way using Reflection or JavaObject to access the menu items to manipulate them.
I've tried poking around to see how the menu is implemented in B4A but have come up against a blank wall with B4AActivity.addMenuItem whose concrete implementation I can't find. Should I give up now or later?
For the few apps I write for Android I adopt a very clean (in my opinion ) aesthetic using only the main menu on the title bar of an activity. This sort of mimics a desktop app with just a main menu bar. I don't like animations and fancy colored thingies etc. Using the main menu in a B4XPages app means that each page defaults to having the same main menu items and the menu events are raised in Main. I have been trying to customise this for each B4XPage. I have tried adding menu items within each page using this in B4XPage_Create.
B4X:
Dim act As Activity = B4XPages.GetNativeParent(Me)
act.AddMenuItem("Fred", "Menu")
' or
Dim act As Activity = Root1
act.AddMenuItem("Fred", "Menu")
Having added the menu items I think I can mange to call into each B4XPage as required from the menu event Subs in main. However I now need a mechanism to remove or hide the unwanted items according to which page is displayed. I don't think the menu items can be removed once added but I think they can be individually enabled/disabled and hidden if required. So secondly is there a way using Reflection or JavaObject to access the menu items to manipulate them.
I've tried poking around to see how the menu is implemented in B4A but have come up against a blank wall with B4AActivity.addMenuItem whose concrete implementation I can't find. Should I give up now or later?