I'm trying to make an application that when I select an item, put a panel above with certain options, but at the height of the selected item.
A kind of spinner, but made to measure. That when I click on a button, I display options with the position relative to the button pressed.
Thanks for your answer, but in my case, I think fits better Clv.FirstVisibleItem.
B4X:
Sub CLV1_ItemClick (Index As Int, Value As Object)
Dim clvitem As CLVItem
clvitem = CLV1.GetRawListItem(Index)
Log("Offset: " & clvitem.Offset & " Size: " & clvitem.Size)
Dim YPos = (Index - CLV1.FirstVisibleIndex) * clvitem.size As Int
Log("Relative YPos: " & YPos)
Dim item As ClvPedidosItem = Value
Log("Index clicked: " & Index & " - Cliente: " & item.LblCliente.Text)
ToastMessageShow("Index clicked: " & Index & " - Cliente: " & item.LblCliente.Text, True)
Log("****")
End Sub
Because I need the relative position with respect to the visible items, not with respect to all the items in the list.
Applied to click on an SD_Spinner located in a CustomListView and then be able to place the corresponding options at the corresponding height.
B4X:
Globals
Dim OffsetFirst As Int
Sub CLV1_ScrollChanged (Offset As Int)
OffsetFirst = Offset
End Sub
Sub SD_Spinner1_Click(Panel As Panel)
Dim Index As Int
Index = CLV1.GetItemFromView(Panel)
Dim clvitem As CLVItem
clvitem = CLV1.GetRawListItem(Index)
TopAux = clvitem.Offset - OffsetFirst + (Panel.top + Panel.Height)
LeftAux = Panel.Left
Log("--"&TopAux)
End Sub