B4A Library RSPopupMenu

RSPopupMenu
Screenshot_2014-08-06-16-33-37.png

Click the picture to see the image.
RSPopupMenu wraps the native Android PopupMenu (API 11+) and attaches a PopUpMenu to a view.
You can add menu's or submenus and 2 events are called:

B4X:
public sub Initialize
dim PopupMenu As RSPopupMenu
'Initialize the PopupMenu
    PopupMenu.Initialize("PopupMenu", ivPopup)
    PopupMenu.AddMenuItem(0, 0, "View")
    PopupMenu.AddMenuItem(1, 1, "Edit")
    PopupMenu.AddMenuItem(2, 2, "Details")
    PopupMenu.AddMenuItem(3, 3, "Remove")
end sub

Sub ivPopup_Click
    PopupMenu.Show
 
End Sub

Sub PopupMenu_Dismiss
    ToastMessageShow("PopupMenu dismissed", False)
End Sub

Sub PopupMenu_MenuItemClick (ItemId As Int) As Boolean
    ToastMessageShow("Item " & ItemId & " clicked.", False)
    Return False
End Sub


RSPopupMenu

Author: XverhelstX
Version: 1
  • RSPopupMenu
    Methods:
    • AddMenuItem (ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddMenuItem2 (GroupId As Int, ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddSubMenuItem (ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddSubMenuItem2 (GroupId As Int, ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • Dismiss
      Dismiss the menu popup.
    • Initialize (EventName As String, view As ConcreteViewWrapper)
      Initializes the Popup Menu.
      A PopupMenu displays a Menu in a modal popup window anchored to a View.
      The popup will appear below the anchor view if there is room, or above it if there is not.
      If the IME is visible the popup will not overlap it until it is touched.
      Touching outside of the popup will dismiss it.
    • Initialize2 (EventName As String, view As ConcreteViewWrapper, Gravity As Int)
      Initializes the Popup Menu.
      A PopupMenu displays a Menu in a modal popup window anchored to a View.
      The popup will appear below the anchor view if there is room, or above it if there is not.
      If the IME is visible the popup will not overlap it until it is touched.
      Touching outside of the popup will dismiss it.
    • IsInitialized As Boolean
    • Show
      Show the menu popup anchored to the view specified during construction.

Kind regards,
Tomas
 

Attachments

  • RSPopupMenu.zip
    5.1 KB · Views: 1,610

JonRubin

Member
Licensed User
Longtime User
Thank you Robert, I will definitely do that if no one can come up with a solution to access the data that should already be available. Thanks! Jon
 

Troberg

Well-Known Member
Licensed User
Longtime User
B4X:
AddMenuItem (ItemId As Int, Order As Int, Title As String) Add a new item to the menu.

AddSubMenuItem (ItemId As Int, Order As Int, Title As String) Add a new item to the menu.
AddSubMenuItem2 (GroupId As Int, ItemId As Int, Order As Int, Title As String) Add a new item to the menu.

AddMenuItem works fine. What does AddSubMenuItem and AddSubMenuItem2 do?

When I called ALL they do is the same thin AddMenuItem does which is add a menuitem

I though they would create a sub sub menuitem

Same thing for me, and I'm curious about how to get the submenu behaviour as expected.
 

jarda

Member
Licensed User
Longtime User
RSPopupMenu
View attachment 26831

Click the picture to see the image.
RSPopupMenu wraps the native Android PopupMenu (API 11+) and attaches a PopUpMenu to a view.
You can add menu's or submenus and 2 events are called:

B4X:
public sub Initialize
dim PopupMenu As RSPopupMenu
'Initialize the PopupMenu
    PopupMenu.Initialize("PopupMenu", ivPopup)
    PopupMenu.AddMenuItem(0, 0, "View")
    PopupMenu.AddMenuItem(1, 1, "Edit")
    PopupMenu.AddMenuItem(2, 2, "Details")
    PopupMenu.AddMenuItem(3, 3, "Remove")
end sub

Sub ivPopup_Click
    PopupMenu.Show

End Sub

Sub PopupMenu_Dismiss
    ToastMessageShow("PopupMenu dismissed", False)
End Sub

Sub PopupMenu_MenuItemClick (ItemId As Int) As Boolean
    ToastMessageShow("Item " & ItemId & " clicked.", False)
    Return False
End Sub


RSPopupMenu

Author: XverhelstX
Version: 1
  • RSPopupMenu
    Methods:
    • AddMenuItem (ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddMenuItem2 (GroupId As Int, ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddSubMenuItem (ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • AddSubMenuItem2 (GroupId As Int, ItemId As Int, Order As Int, Title As String)
      Add a new item to the menu.
    • Dismiss
      Dismiss the menu popup.
    • Initialize (EventName As String, view As ConcreteViewWrapper)
      Initializes the Popup Menu.
      A PopupMenu displays a Menu in a modal popup window anchored to a View.
      The popup will appear below the anchor view if there is room, or above it if there is not.
      If the IME is visible the popup will not overlap it until it is touched.
      Touching outside of the popup will dismiss it.
    • Initialize2 (EventName As String, view As ConcreteViewWrapper, Gravity As Int)
      Initializes the Popup Menu.
      A PopupMenu displays a Menu in a modal popup window anchored to a View.
      The popup will appear below the anchor view if there is room, or above it if there is not.
      If the IME is visible the popup will not overlap it until it is touched.
      Touching outside of the popup will dismiss it.
    • IsInitialized As Boolean
    • Show
      Show the menu popup anchored to the view specified during construction.

Kind regards,
Tomas

Hi

How do I put a SubMenu?

Jarek
 

Devv

Active Member
Licensed User
Longtime User
Very nice and usefull lib

why did we used "Return False"

B4X:
Sub PopupMenu_MenuItemClick (ItemId As Int) As Boolean
    ToastMessageShow("Item " & ItemId & " clicked.", False)
    Return False
End Sub
 

xor83

Member
Licensed User
Longtime User
Great lib !!

But when i try use with a list like UltimateListView the popup is displayed out of place. See picture when i touch in the first line:

popup.png
Did anyone found the solution for above issue?
 
Top