Hi All.
I m folowing the @Erel example of xClv with a lot of items
https://www.b4x.com/android/forum/threads/b4x-xui-customlistview-lazy-loading-virtualization.87930/
but i have a problem, i m geting a LAG when i move the scroll to down or to top.
I'd like to know if I'm doing something wrong in my code.
this sub is what i m using to add 10000 itens on clv.
and here is my VisibleRangeChanged sub
Is there a problem with my code? I tried to review and redo but the lag continues.
on my list there are no pictures.
obs: the lag occurs in debug and release too.
here is my layout "pedidosEnviados", dont have images, only 3 labels and 2 panels.
how can i make a clv suport 10.000 items or more with no lag?
thx all
I m folowing the @Erel example of xClv with a lot of items
https://www.b4x.com/android/forum/threads/b4x-xui-customlistview-lazy-loading-virtualization.87930/
but i have a problem, i m geting a LAG when i move the scroll to down or to top.
I'd like to know if I'm doing something wrong in my code.
this sub is what i m using to add 10000 itens on clv.
B4X:
Sub Carrega_PedidosEnviados
scConteudoPrincipal.Panel.RemoveAllViews
scConteudoPrincipal.Panel.Height = 100%y
scConteudoPrincipal.Panel.LoadLayout("pedidosEnviados")
pFundoPrincipal.Height = 100%y
scConteudoPrincipal.Panel.Height = pFundoPrincipal.Height
lbTituloActionBar.Text = "PEDIDOS ENVIADOS"
For i = 1 To 10000
Dim cd As DataClvPedidosEnviados
cd.Initialize
cd.titulo = "Farol direito Palio Weekend 2010"
cd.desc = "Farol lado do passageiro da Palio Weekend ELX..."
cd.numeroPedido = "Pedido: 10536"
cd.hora = "25/02/2018 15:35"
If i Mod 2 == 0 Then
cd.cor = 0xFFafafaf
Else
cd.cor = 0xFF8b8b8b
End If
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clvPedidosEnviados.AsView.Width, 15%y)
clvPedidosEnviados.Add(p, cd)
Next
pPrincipal.Visible = True
End Sub
and here is my VisibleRangeChanged sub
B4X:
Sub clvPedidosEnviados_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 5
For i = 0 To clvPedidosEnviados.Size - 1
Dim p As B4XView = clvPedidosEnviados.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
'visible+
If p.NumberOfViews = 0 Then
Dim cd As DataClvPedidosEnviados = clvPedidosEnviados.GetValue(i)
p.LoadLayout("clvPedidosEnviados")
Private cs As CSBuilder
cs.Initialize
cs.Bold.Size(13).Append(cd.titulo).Append(CRLF).PopAll
cs.VerticalAlign(3dip)
cs.Append(cd.desc).PopAll
lbDescPedidoClvPedidosEnviados.Text = cs
If i Mod 2 == 0 Then
pClaroClvPedidosEnviados.Color = cd.cor
lbDescPedidoClvPedidosEnviados.Color = cd.cor
Else
pClaroClvPedidosEnviados.Color = 0xFF8b8b8b
lbDescPedidoClvPedidosEnviados.Color = cd.cor
End If
End If
Else
'not visible
If p.NumberOfViews > 0 Then
p.RemoveAllViews
End If
End If
Next
End Sub
B4X:
Type DataClvPedidosEnviados (titulo As String, desc As String, numeroPedido As String ,hora As String, cor As Int)
Is there a problem with my code? I tried to review and redo but the lag continues.
on my list there are no pictures.
obs: the lag occurs in debug and release too.
here is my layout "pedidosEnviados", dont have images, only 3 labels and 2 panels.
how can i make a clv suport 10.000 items or more with no lag?
thx all
Last edited: