Android Question AppCompat - ACPopupMenu Usage

Discussion in 'Android Questions' started by dwsands, Jun 23, 2017.

  1. dwsands

    dwsands Member Licensed User

    Does anyone have an example of using the ACPopupMenu on a toolbar action?

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. dwsands

    dwsands Member Licensed 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.
     

    Attached Files:

    Last edited: Jun 25, 2017
  4. johndb

    johndb Active Member Licensed User

    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: Jun 26, 2017
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can add a custom view instead of a standard menu item:
    [​IMG]


    Code:
    Dim b As Button
       b.Initialize(
    "menuButton")
       b.Text = 
    "Click"
       ACToolBarLight1.AddView(b, 
    60dip40dipGravity.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
     
    jose luis gudino likes this.
  6. dwsands

    dwsands Member Licensed User

    To @johndb and @Erel, thanks!

    @Erel could you provide the source for your example?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice