Android Question xCustomListview 1.50 Recycle View

XbNnX_507

Active Member
Licensed User
Longtime User
is it possible to use VisibleRangeChanged event to reuse the views in runtime instead of creating and removing these?
( similar to the way recycle view works).
if so. an example would be great. thanks.
 

XbNnX_507

Active Member
Licensed User
Longtime User
Yes it is very fast loading the empty panels to be used. But then we need to deal with scrolling being very jumpy and jerky when
this code is called. ( +10000 items in clv )
B4X:
Sub CLV1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    Dim ExtraSize As Int = 20
    For i = 0 To CLV1.Size - 1
        Dim p As B4XView = CLV1.GetPanel(i)
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            'visible+
            If p.NumberOfViews = 0 Then
                Dim cd As CardData = CLV1.GetValue(i)
                p.LoadLayout("Card1")  '<- CONSTANT LOADING VERY SLOW 
                lblTitle.Text = cd.Title
                lblContent.Text = cd.Content
                SetColorStateList(lblAction1, xui.Color_LightGray, lblAction1.TextColor)
                SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
                ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, cd.BitmapFile, ImageView1.Width, ImageView1.Height, True))
            End If
        Else
            'not visible
            If p.NumberOfViews > 0 Then
                p.RemoveAllViews '<--- <- CONSTANT REMOVING VERY SLOW 
            End If
        End If
    Next
End Sub

anyway in the meantime i'll be using UltimateListView which is better optimized for what i need.
i'll be looking for an alternative for B4J which is where the problem above is most obvious in debug and release mode.
Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
p.RemoveAllViews '<--- <- CONSTANT REMOVING VERY SLOW
It is unlikely that this step is slow.

The problem with B4J is different. In B4A and B4i the scrolling is linear. This is not the case in B4J where moving the scrollbar jumps to a different location in the list so all the items need to be created immediately. If you like start a new thread in B4J forum and I can post an example where the views are reused. It shouldn't be difficult.
 
Upvote 0
Top