Android Question Unknown type: menuitem Are you missing a library reference?

WofaCle

Member
Good day everyone please i have encounter problem with the below line of code help me fix it

B4X:
Private Sub More_Click
    Dim pop As PopupMenu
    Dim v As View
   
    v = Sender
   
    pop.Initialize("PopupMenu", v)
    'pop.AddMenuItem(1, "Share App", Null)
    'pop.AddMenuItem(2, "Rate App", Null)
    pop.AddMenuItem(3, "Anthem Audio", Null)
   
    pop.Show
End Sub


Sub PopupMenu_ItemClicked (Item As MenuItem)
    Select Item.Id
        Case ShareApp
'            Dim Intent As Intent
'            Intent.Initialize(Intent.ACTION_VIEW, "https://www.youtube.com/channel/UCCAK20OTGH7Tgd-ubETJd3g?view_as=subscriber")
'            StartActivity(Intent)
        Case RateApp
'            Dim Intent As Intent
'            Intent.Initialize(Intent.ACTION_VIEW, "https://www.google.com")
'            StartActivity(Intent)
        Case AnthemAudio
            Activity.LoadLayout("Music")
           
    End Select
   
End Sub
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
item.id's are ints, not strings: case 1, case 2, case 3. not case ShareApp, etc.
if you want the item's title, use item.title
 
Upvote 0

WofaCle

Member
Please it didn't work......
The problem is from "PopupMenu" and "Sub PopupMenu_ItemClicked (Item As MenuItem)"
There's a red line under it. But i have As PopupaMenu library in my libraries or is there other library i must use
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the ASPopupMenu library uses ASPopupMenu_Item, not menuitem
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Please attach your project if possible or an example with the same issue for us to check.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
@WofaCle
If your idea is to use the ASPopUpMenu then I think that your code was quite messy and wrong.
But I am not familiar with ASPopUpMenu.
I just tried to make the menu work, as I guessed it was intended to.
Check if this can be a start for what you are trying to achieve.
But you need to check much more carefully the ASPopUpMenu example from the author thread (HERE) because you was missing all the initialization part and more, if you was trying to implement it.
Hope this can help a bit.
Take your time to study and understand.
 

Attachments

  • App1_mod.zip
    35.3 KB · Views: 84
Upvote 0

WofaCle

Member
Okay Senior thank you so much am grateful
 
Upvote 0

WofaCle

Member
@Segenut please kindly send me hi private message i wanted to message you but am not able to find a buttom to click and send you message
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Private messaging it's allowed only between Licensed Users.
To become Licensed simply make a donation to support the B4X Development.
You can find the link HERE.
Being Licensed will also make your messages to appear immediately making easier and faster to receive help.
For questions about coding anyway you should continue to ask publicly in the forum.
You will receive much more help and from many users that knows much more.
No question it's stupid in the process of learning, so don't be worried about this in the case.
Spend some time trying to use the search function, many many times you will find the same question that is in your mind already solved.
But for any clarification then open a new thread and ask what you need.
Do not write in other threads when you see that the last message is some months old.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…