Android Question CustomListView and UpdateVisibleRange Event

MarcoRome

Expert
Licensed User
Longtime User
Hi All.
I have this code:

B4X:
................
Dim cd As CardData
                        cd.Initialize
                        cd.Text = cs
                        cd.Text1 = cs1
                        cd.Text2 = cs2
                        cd.riga = i
                        cd.passa_id = m.Get("titolo")&"|"&m.Get("prezzo_mini")&"|"&m.Get("prezzo_max")&"|"&m.Get("tipo_pizza_mini_maxi")&"|"&m.Get("ordine")
                        cd.tipo_menu = tipo_menu
                        cd.tipo_immagine = m.Get("tipo_immagine")
                        Dim p As B4XView = xui.CreatePanel("")
                        p.Color = Colors.ARGB(255, 160,68,29)
                        p.SetLayoutAnimated(0, 0, 0, clv.AsView.Width, 180dip)
                        clv.Add(p, cd)

this code trigger the event:

Sub clv_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)

So if in my select i read n. records, work, if i have in my select one result ( 1 record ) work the first time, but if i repeat a select that give me again 1 record the event no Trigger.

i think that the problem is inside CustomListView here:
B4X:
Private Sub UpdateVisibleRange
    If MonitorVisibleRange = False Then Return
    Dim first As Int = getFirstVisibleIndex
    Dim last As Int = getLastVisibleIndex
    If first <> FirstVisibleIndex Or last <> LastVisibleIndex Then
        FirstVisibleIndex = first
        LastVisibleIndex = last
        CallSubDelayed3(CallBack, EventName & "_VisibleRangeChanged", FirstVisibleIndex, LastVisibleIndex)
    End If
End Sub

Why this line:

If first <> FirstVisibleIndex Or last <> LastVisibleIndex Then....

Thank you
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
So if in my select i read n. records, work, if i have in my select one result ( 1 record ) work the first time, but if i repeat a select that give me again 1 record the event no Trigger.
Please explain. What are you doing that should cause the VisibleRangeChanged event to be raised again?
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi Erel.
I have a Edit text where i insert what i want to look for and I get the result back ( is simple select )
So for example if i search for "xxxx" i get 3 records, if i search "yyyy" i get 1 records. If i try to perform a search that returns me the same number of records (in this case 1) the event is not triggered.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Look example this movie:


i found the first time "margherita" and i have 2 records, the next time i search "Pizza al taglio farcito" and i have 1 Records,
well if i try with another result that give me again 1 result the event isnt trigger.....
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
I understand but the initial list is 400 items. For this reason i used.
Anyway i will use both to load a list with many records, the other to do searches with few records
Thank you for your support
 
Last edited:
Upvote 0
Top