Bug? CustomListView IndexFromOffset

stevel05

Expert
Licensed User
Longtime User
The indexfromoffset method returns two different values dependent on where in the item you touch if the list is scrolled such that the first visible view is only partially visible.
 

Attachments

  • CLVItemFromIndex.zip
    9.5 KB · Views: 163

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are not using this method correctly:
B4X:
Private Sub Overlay_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
   Log("IndexFromOffset " & CustomListView1.FindIndexFromOffset(Y))
   Return False
End Sub
The offset parameter is relative to the tall inner panel. The valid range of values goes from 0 to CustomListView1.sv.ScrollViewContentHeight.
Correct code:
B4X:
Log("IndexFromOffset " & CustomListView1.FindIndexFromOffset(Y + CustomListView1.sv.ScrollViewOffsetY))
 
Top