iOS Question CustomListView Remove item with animation


Well-Known Member
Licensed User
Longtime User
hi everyone, i'm trying to achieve an cool effect when removing an item from a clv.
i had a clv with some custom panels in it. each custom panel had a delete button.
When the delte button is pressed I want the panel to exit from the screen animated, and all the item above scroll up to fill in the space leaved from the item removed.

This is my first attempt (not fully working) (look at the titles to understand the movements):

one problem is that the last item do not go up at the top (i think there is an easy solution, but for the moment i leaved it like so, for focus on more importanti things)
If i remove an element in the middle everything glitches :(

the code i tryed out:

Sub btnDelete_Click
    Dim index As Int = ads_clv.GetItemFromView(Sender)
    Dim pnl As B4XView = ads_clv.GetPanel(index)   
    Dim innerPanel As B4XView = pnl.GetView(0)   
    Dim btn As B4XView                           
    btn = innerPanel.GetView(2) 'ignore'
    innerPanel.SetLayoutAnimated(100, -innerPanel.Width, innerPanel.Top, innerPanel.Width, innerPanel.Height) 'scrolls the card left out of the screen'
    ads_clv.ScrollToItem(index+1) 'scrolls the clv to the item after the disappeard one'
    Sleep(400) 'wait a bit to finish the animations'
    ads_clv.RemoveAt(index) 'actually remove the item i scolled to the left'
    ads_clv.JumpToItem(index) 'jump to the new index (so, the "index+1" of before)', with out this line, after the RemoveAt it shows the wrong one
    If ads_clv.Size == 0 Then 'if the list is now empty
        'do something'
    End If
End Sub