Hello Erel
This post is kinda wish or a question if it is achievable with current B4A capabilities.
I'm writing something serious and as it's obvious from other topics of mine, I am aiming at reusability. But because I can't pass an Activity to a function by reference, I am copying the same code in every Activity.
Sample code which is copied:
addMenus() - a function in Activity modules.
Now, if it was possible to put the above method into a code module and do the following in Activity_Create
addMenus(ThisActivity) ' of course it can be the activity name too.
This post is kinda wish or a question if it is achievable with current B4A capabilities.
I'm writing something serious and as it's obvious from other topics of mine, I am aiming at reusability. But because I can't pass an Activity to a function by reference, I am copying the same code in every Activity.
Sample code which is copied:
addMenus() - a function in Activity modules.
B4X:
Sub addMenus()
Dim i As Int
Dim menus As Map
menus.Initialize
Dim thisKey As String
Dim thisMenuItem As MENU_ITEM
' get all menus depending on the activity
menus = Common.getMenusByActivity(menu_prefix) ' E.g $$Main$$
For i = 0 To menus.Size - 1
thisKey = menus.GetKeyAt(i)
thisMenuItem = menus.GetValueAt(i)
Activity.AddMenuItem2(thisMenuItem.displayText, thisMenuItem.event, thisMenuItem.icon)
Next
'Activity.AddMenuItem("About","menu")
End Sub
Now, if it was possible to put the above method into a code module and do the following in Activity_Create
addMenus(ThisActivity) ' of course it can be the activity name too.