iOS Question CustomListView items to buttom with ScrollToItem

Cadenzo

Active Member
Licensed User
Longtime User
When a CustomListView in B4i has not enough list items, to fill the screen, it shows the items on the buttom, In that moment, when .ScrollToItem is called.

B4X:
clv.ScrollToItem(iIndex) 'why items to the buttom?
 

Attachments

  • IMG_0316.PNG
    IMG_0316.PNG
    146.4 KB · Views: 54
  • IMG_0317.PNG
    IMG_0317.PNG
    138.6 KB · Views: 63
  • IMG_0318.PNG
    IMG_0318.PNG
    110.1 KB · Views: 49

Cadenzo

Active Member
Licensed User
Longtime User
Thanks! In my app it was not a good behavior. I helped me now with this code:
B4X:
Sub JumpToListItem(clv As CustomListView, index As Int, animated As Boolean)
    If clv.Size > index Then
        #if B4i 'avoid jumping items to the buttom (behavior of the underlying UIScrollView control)
        If clv.FirstVisibleIndex = 0 And clv.LastVisibleIndex = clv.Size - 1 Then Return 'all items are visible anyhow
        #End If
        
        If animated Then
            clv.ScrollToItem(index)
        Else
            clv.JumpToItem(index)   
        End If
    End If
End Sub
 
Upvote 0
Top