Android Question What is ExtraSize in xCustomListView

Pooya1

Active Member
Licensed User
Hi
in xCustomListView,there is VisibleRangeChanged event that have FirstIndex and LastIndex
According of below code,we show data in list
B4X:
Sub CLV1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 20
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clv1.Size - 1)
        Dim p As B4XView = clv1.GetPanel(i)
        If p.NumberOfViews = 0 Then
            '**************** this code is similar to the code in CreateItem from the original example
            p.LoadLayout("f2")
            p.GetView(0).Color    =    Colors.RGB(Rnd(1,255),Rnd(1,255),255)
            p.GetView(1).Tag    =    i
        End If
    Next
End Sub


In this code,what is ExtraSize? why 20 value for it?
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Where is it?
I had not seen that event because I had downloaded the project, thinking it contained the latest version of xCustomListView which instead is attached separately.



If I understand well, that event, VisibleRangeChange, is used in the examples to fill 1,000 items "quickly" and to empty non-visible items.

In this code,what is ExtraSize? why 20 value for it?
Again if I understand well :), ExtraSize is an arbitrary value used supposing that ExtraSize or less items are shown.
Instead of filling all the 1,000 items at once, the event is used to fill only those currently shown if they are not already filled.

[This is not the best moment to think/study better, for me; so I can not investigate the code more]
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
[This is not the best moment to think/study better, for me; so I can not investigate the code more]
Despite this, I looked better at the sample code.

ExtraSize (still an arbitrary value) is considered/used as "number of items before and after those displayable".
In the example, when the "visible range" changes (then in the event routine), the items between the first visible - ExtraSize and the last visible + Extrasize are checked and, if they are empty, they will be filled.

If you know the maximum number of items displayable, I think you could set ExtraSize to this number (this would be as you "fill 3 pages of items", one page before not visible, one page visible, one page after not visible).


Sorry, I don't know how to explain this better :D:(
 
Last edited:
Upvote 0

Pooya1

Active Member
Licensed User
I had not seen that event because I had downloaded the project, thinking it contained the latest version of xCustomListView which instead is attached separately.



If I understand well, that event, VisibleRangeChange, is used in the examples to fill 1,000 items "quickly" and to empty non-visible items.


Again if I understand well :), ExtraSize is an arbitrary value used supposing that ExtraSize or less items are shown.
Instead of filling all the 1,000 items at once, the event is used to fill only those currently shown if they are not already filled.

[This is not the best moment to think/study better, for me; so I can not investigate the code more]
When i change extrasize to any value,it worked again properly why?o_O
 
Upvote 0
Top