Android Question how to properly delete item from CLV in Loop ?

Addo

Well-Known Member
Licensed User
Longtime User
i am trying to delete some clv items based on some if condition by doing the following


B4X:
For c = 0 To CLVLIST.Size - 1
Dim p As B4XView = CLVLIST.GetPanel(c)
If p.GetView(5).Text = "state" Then
CLVLIST.RemoveAt(c)
End If

Next

i get the following error


 

mangojack

Expert
Licensed User
Longtime User
You are reducing the size of CLV as you remove items ... you must loop in reverse.

something like

B4X:
 For c = CLV.Size - 1 To 1 Step -1
       CLV.RemoveAt(c)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…