Sub CLVList_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 25 'Add 25 items at a time, this can be changed to suite your requirements
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CLVList.Size - 1) 'Loop for adding/removing your items layout to or from the list
Dim Pnl As B4XView = CLVList.GetPanel(i) 'Declare a new B4XView
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then 'Add a new item to the list
If Pnl.NumberOfViews = 0 Then 'Add items to the list
Dim TD As TestData = CLVList.GetValue(i) 'Get your custom Type
Pnl.LoadLayout("ItemInfo") 'Load your
'ImageView1.Bitmap=LoadBitmap(File.DirAssets, "glass.png")
LblNum.Text = TD.LabelNum 'Self-explanatory
LblText.Text = TD.LabelProduct 'Self-explanatory
btnBadge.Tag = LblNum
ImageView1.SetBitmap(XUI.LoadBitmapResize(File.DirAssets, TD.BitmapFile, ImageView1.Width, ImageView1.Height, True))
End If
Else 'Remove items from the list
If Pnl.NumberOfViews > 0 Then
Pnl.RemoveAllViews 'Remove none visible item from the main xCLV layout
End If
End If
Next
End Sub