Android Question CostumListView and Slide Menu

BitsAndBytes

Active Member
Licensed User
I have a costume list view with 5 items. Each item has a button. How i can show a menu in the position of item, each time user press a button from a costume list view item?
 

mangojack

Expert
Licensed User
Longtime User
If you are using CustomListView class, change Class Global - panels As List to Public.
Place some menu item labels on a panel ... then
B4X:
Sub Button1_Click 
    Dim index As Int = clv1.GetItemFromView(Sender) 
    Dim pnl As Panel = clv1.panels.Get(index)        'panels' is now Public   
    pnlMenu.SetLayout(0, pnl.top, 0, 0)
    pnlMenu.SetLayoutAnimated(400, 200dip ,pnl.Top, 200dip, 200dip)
    pnlMenu.BringToFront  ' or pnlMenu.Elevation = 1 
End Sub
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
All this code does is gets the top position of the Parent panel holding your Item Panel and its views.
This allows you to correctly position your menu panel.

'get the index of the item / row containing the clicked button ..
B4X:
Dim index As Int = clv1.GetItemFromView(Sender)
'you can now get the top position of the items 'Parent' panel by ..
B4X:
Dim pnl AsPanel = clv1.panels.Get(index)  'to access 'Panels list from your module, change CLV Class Global - panels As List to Public.
MyMenuPanel.top = pnl.top   ' or whatever position you like.

If you are using the CLV Library , I do not know how to get reference to the Parent panel top position ..
You could always do calculation, knowing the button / item that was clicked ..
Item height + divider height *item index = top position.

Did you test the above code .. the result might not be to your liking anyway.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…