Using the ACToolbar and all working fine, except I am unable to access the menu items outside
the Sub Activity_CreateMenu. I need to enable or disable certain overflow menu items, depending
on the active panel. When I try to do this in the Sub that handles the various panels:
I get a crash as mentioned.
I can see why this is as if I do:
Log(ActionBar.Menu.Size)
I get zero.
When I do the same at the end of Sub Activity_CreateMenu I get the expected number of 20.
This is the code creating the menu:
Any idea what I might be doing wrong?
RBS
the Sub Activity_CreateMenu. I need to enable or disable certain overflow menu items, depending
on the active panel. When I try to do this in the Sub that handles the various panels:
B4X:
ActionBar.Menu.FindItem(9).Enabled = (iPanelType = ePanelType.SQLEdit)
ActionBar.Menu.FindItem(10).Enabled = (iPanelType = ePanelType.SQLEdit)
ActionBar.Menu.FindItem(11).Enabled = (iPanelType = ePanelType.SQLEdit)
I get a crash as mentioned.
I can see why this is as if I do:
Log(ActionBar.Menu.Size)
I get zero.
When I do the same at the end of Sub Activity_CreateMenu I get the expected number of 20.
This is the code creating the menu:
B4X:
#IgnoreWarnings: 11
Sub Activity_CreateMenu(Menu As ACMenu)
Dim item As ACMenuItem
Menu.Clear
item = Menu.Add2(1, 1, " Find", TextToBitmapDrawable("F", 24, Colors.RGB(0, 0, 0)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(2, 2, " Pat", TextToBitmapDrawable("P", 24, Colors.RGB(0, 0, 255)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(3, 3, " Meds", TextToBitmapDrawable("M", 24, Colors.RGB(255, 0, 0)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(4, 4, " Vals", TextToBitmapDrawable("V", 24, Colors.RGB(0, 192, 0)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(5, 5, " Clin", TextToBitmapDrawable("C", 24, Colors.RGB(255, 0, 255)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(6, 6, " BP", TextToBitmapDrawable("B", 24, Colors.RGB(0, 255, 255)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
'overflow menu (3 dots)
'----------------------
item = Menu.Add(7, 7, " Settings", Null)
item = Menu.Add(8, 8, " SQL", Null)
item = Menu.Add(9, 9, " Clear SQL", Null)
item = Menu.Add(10, 10, " Copy SQL", Null)
item = Menu.Add(11, 11, " Paste SQL", Null)
item = Menu.Add(12, 12, " Phone Patient", Null)
item = Menu.Add(13, 13, " Text Patient", Null)
'note overflow can't do submenu's
'--------------------------------
item = Menu.Add(14, 14, "-Add To Patient List", Null)
item = Menu.Add(15, 15, "-Remove from Patient List", Null)
item = Menu.Add(16, 16, "-Show Patient List", Null)
item = Menu.Add(17, 17, "-Clear Patient List", Null)
item = Menu.Add(18, 18," Make Chart", Null)
item = Menu.Add(19, 19, " About", Null)
item = Menu.Add(20, 20, " Exit", Null)
'will be fine here, 20 menu items
'General.RunLog("GotoPanel, menu items: " & ActionBar.Menu.Size)
End Sub
Any idea what I might be doing wrong?
RBS