Android Question AppCompat - ACPopupMenu Usage

dwsands

Member
Licensed User
Longtime User
Does anyone have an example of using the ACPopupMenu on a toolbar action?

Thanks
 

dwsands

Member
Licensed User
Longtime User
There is already an overflow menu, if that is what you are referring to. I am wanting to have an separate menu popup when the filter icon is selected, so yes another menu is needed. The ACPopupMenu requires a view when it is initialized and the closest view I can think of is the toolbar itself which puts it way too far from the icon the popup menu is associated with. If the filter icon is a view, then that would work perfectly, but I cannot determine if or how to refer to the filter icon as a view.
 

Attachments

  • Toolbar.jpg
    Toolbar.jpg
    23.2 KB · Views: 756
Last edited:
Upvote 0

johndb

Active Member
Licensed User
Longtime User
There is already an overflow menu, if that is what you are referring to. I am wanting to have an separate menu popup when the filter icon is selected, so yes another menu is needed. The ACPopupMenu requires a view when it is initialized and the closest view I can think of is the toolbar itself which puts it way too far from the icon the popup menu is associated with. If the filter icon is a view, then that would work perfectly, but I cannot determine if or how to refer to the filter icon as a view.
What I do is create a very small transparent panel which is 2 X 2 pixels and locate it at activity.width and 0 y. Use that panel as the popup's reference view. I have also adjusted the Y to the height of the toolbar if you want the popup below the toolbar.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can add a custom view instead of a standard menu item:
SS-2017-06-26_10.50.34.png



B4X:
Dim b As Button
   b.Initialize("menuButton")
   b.Text = "Click"
   ACToolBarLight1.AddView(b, 60dip, 40dip, Gravity.CENTER)
   
   pp.Initialize("pp", b) 'global ACPopupMenu
   pp.AddMenuItem(0, "Item 1", Null)
   pp.AddMenuItem(0, "Item 2", Null)
   pp.AddMenuItem(0, "Item 3", Null)
End Sub


Sub MenuButton_Click
   pp.Show
End Sub
 
Upvote 0
Top