When you list an item, when you refresh the list, VisibleRangeChanged event is not executed.
B4X:
Sub refresh_Click
FillList2
End Sub
Sub FillList2
Dim bitmaps As List = Array("logo.png")
Dim n As Long = DateTime.Now
CLV1.Clear
ItemList.Initialize
ModConn.c = ModConn.s.ExecQuery("SELECT * FROM pedidos ORDER BY ID DESC;")
If ModConn.c.RowCount <> 0 Then
For i = 0 To ModConn.c.RowCount-1
ModConn.c.Position = i
Dim cd As CardData
cd.Initialize
ItemList.Add(ModConn.c.GetInt("ID"))
cd.Patente = ModConn.c.GetString("PATENTE")
cd.Tara = ModConn.c.GetDouble("TARA")
cd.Carga = ModConn.c.GetDouble("CARGA")
cd.Total = ModConn.c.GetDouble("PESO_TOTAL")
cd.Fecha = ModConn.c.GetString("FECHA")
cd.Operador = ModConn.c.GetString("COD_DESPACHADOR")
cd.NumGuia = ModConn.c.GetInt("N_GUIA")
cd.BitmapFile = bitmaps.Get((0) Mod bitmaps.Size)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, CLV1.AsView.Width, 280dip)
CLV1.Add(p, cd)
Next
End If
ModConn.c.Close
Log("Tamaño Lista: "&ItemList.Size)
Log("Loading cards took: " & (DateTime.Now - n) & "ms")
End Sub
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)
Log("FirstIndex - ExtraSize: "&(FirstIndex - ExtraSize))
Log("LastIndex + ExtraSize: "&(LastIndex + ExtraSize))
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
'visible+
If p.NumberOfViews = 0 Then
Log("NumberOfViews: "&p.NumberOfViews)
Dim cd As CardData = CLV1.GetValue(i)
p.LoadLayout("Card1")
' SetColorStateList(lblAction1, xui.Color_LightGray, lblAction1.TextColor)
' SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
lblFecha.Text = ": "& cd.Fecha
lblPat.Text = ": "& cd.Patente
lblTara.Text = ": "& ModConn.nf.Format(cd.Tara) &" Kg"
lblCarga.Text = ": "& ModConn.nf.Format(cd.Carga) &" Kg"
lblTotal.Text = ": "& ModConn.nf.Format(cd.Total) &" Kg"
lblOperador.Text = ": "& cd.Operador
lblNumGuia.Text = ": "& cd.NumGuia
SetColorStateList(lblPrint, xui.Color_LightGray, lblPrint.TextColor)
If cd.NumGuia <> 0 Then
imgOk.Bitmap = ImgagenOk
Else
imgOk.Bitmap = ImagenNot
End If
ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, cd.BitmapFile, ImageView1.Width, ImageView1.Height, True))
'UpdateItemColor(i, cd.Color) '<-------------
End If
Else
'not visible
If p.NumberOfViews > 0 Then
p.RemoveAllViews
End If
End If
Next
lblPrint.Tag = ItemList
End Sub
Last edited: