Android Question StdActionBarHelper library and MenuItem Members

William Hunter

Active Member
Licensed User
Longtime User
The link below leads to the documentation page for the StdActionBarHelper library:

https://www.b4x.com/android/help/stdactionbarhelper.html#menuitem_enabled

The excerpt below is from this documentation, and lists MenuItem Events and Members. How is it intended that these Members be used
?
Code: Copy
StdActionBarHelper

MenuItem

Events:
None
Members:

Checkable As Boolean

Checked As Boolean

Enabled As Boolean

Icon As android.graphics.drawable.Drawable

Id As Int [read only]

IsInitialized As Boolean

Title As String

Visible As Boolean

Best regards :confused:
 
Having no response to my question, perhaps it wasn't clear. So, I will rephrase it. If one were to create a PopupMenu, using StdActionBarHelper, the code would look somewhat as shown below.
Code: Copy
SubGlobals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim dummy AsPanel
EndSub

SubMenu_Click
'Log("Show popup")
'Add the dummy view to the activity
dummy.Initialize("")
Activity.AddView(dummy, 80%x, 0, 1dip, 1dip)
dummy.Color = Colors.Transparent
'Create and show popup menu
Dim pop AsPopupMenu
pop.Initialize("ABPop", dummy)
pop.AddMenuItem(1, "Connect", GetDrawable("menu_connect"))
pop.AddMenuItem(2, "Disconnect", GetDrawable("menu_disconnect"))
pop.AddMenuItem(3, "Rotate", GetDrawable("menu_rotate"))
pop.AddMenuItem(4, "Credits", GetDrawable("menu_ok"))
pop.AddMenuItem(5, "About", GetDrawable("menu_info"))
pop.Show
EndSub
Now, if one wanted to utilize MenuItem Members, as listed in my post above, to say disable a MenuItem, the code could be expected to look something like that below.
Code: Copy
SubMenuItemDisable
pop.MenuItem(ItemId.Enabled = False)
EndSub
The problem is that pop.MenuItem is not recognized as being valid code. So, this is why I ask – How is it intended that these Members be used. This is something that I need to understand, and would appreciate some guidance. :(
 
Upvote 0
The problem is that pop.MenuItem is not recognized as being valid code.
The problem is that you are using it the wrong way.
pop.AddMenuItem returns the MenuItem (which you need to recognize, store in a variable for later use)
See the documentation of AddMenuItem

popupmenuitem0046.png

Code: Copy
    For i = 0 To 9
        Dim mi As MenuItem
        mi = pop.AddMenuItem(i, "MenuItem " & i, GetDrawable("ic_action_edit"))
        ' you now can use mi to set it disable and so on....
    Next
 
Upvote 0
Back
Top