Hi, need help for CustomList view... I'm filling custom listview with data from my sql database...
I can not understand why is stored Tag empty... Any suggestion...
My code:
I can not understand why is stored Tag empty... Any suggestion...
My code:
1. Creating the x panels with data from my sql (table customers)::
' napolnimo combo z kupci
Sub FillComboCustomer(Filter As String)
Query = $"select cu_code, cu_name, cu_country from cu "$
If Filter <> "" Then
Query = Query & " where cu_name like '%" & Filter & "%' and cu_discontinued = '0' order by cu_code "
Else
Query = Query & "where cu_discontinued = '0' order by cu_code "
End If
Dim rs As ResultSet = OptimusComm.MySql.ExecQuery(Query)
Dim recKupec As typKupci
recKupec.Initialize
Dim i As Int = 0
Do While rs.NextRow
Dim p As B4XView = xui.CreatePanel("")
p.Color = xui.Color_Transparent
p.SetLayoutAnimated(0,0,0, clvKupci.AsView.Width, 30dip)
recKupec.Sifra = rs.GetString("cu_code")
recKupec.Naziv = rs.GetString("cu_name")
recKupec.Drzava = rs.GetString("cu_country")
p.Tag = i
i = i + 1
clvKupci.Add(p, i)
Loop
rs.Close
End Sub
Filling only visible records with data:
Private Sub clvKupci_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
Dim ExtraSize As Int = 20
For i = 0 To clvKupci.Size - 1
Dim pnl As B4XView = clvKupci.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
If pnl.NumberOfViews = 0 Then
Log(pnl.Tag) ' --> here is tag.value stored
pnl.LoadLayout("lstKupec")
Log(pnl.Tag) ' --> tag.value is empty
Dim tSifra As TextField = pnl.GetView(0)
tSifra.Text = pnl.Tag
End If
Else
'Not visible -
If pnl.NumberOfViews > 0 Then pnl.RemoveAllViews '<--- remove the layout
End If
Next
End Sub