dim lstItems as list
lstItems.Initialize
lstItems.AddAll(Array As String("Option 1", "Option 2"))
Private Sub UpdateMenuItems(lstItems As List, iconFile As String)
' Dim bmp As B4XBitmap = CreateIconWithBadge(CartBitmap, BadgeNumber)
'1 clear existing menu items, if any
Dim menus As List = B4XPages.GetManager.GetPageInfoFromRoot(Root).Parent.MenuItems
menus.Clear
'add menu items
'2. add menu items
Dim mi As B4AMenuItem' = B4XPages.AddMenuItem(Me, "cart")
For i =0 To lstItems.Size-1
Dim item As String =lstItems.Get(i)
mi=B4XPages.AddMenuItem(Me, item)
'add icon to first item:
If i=0 And iconFile.Length>0 And File.Exists(File.DirAssets, iconFile) Then
Dim bmp As Bitmap
bmp.Initialize(File.DirAssets, iconFile)
mi.AddToBar = True
mi.Bitmap = bmp
End If
Next
'3 force refresh
Dim ctxt As JavaObject
ctxt.InitializeContext
ctxt.RunMethod("invalidateOptionsMenu", Null)
End Sub