Hi everybody. I want to create custom listview with three different fontsize textview in each row.
Thanks in Advance.
Thanks in Advance.
clv2.Add(CreateListItem($"Item #${i}"$, 160dip, clv2.AsView.Height), $"Item #${i}"$)
5000 lines on my devices usually takes about 5 seconds to populate from an online database, but that does depend on how complicated your CLV is and if you are loading images.
Anyway, you should implement xCustomListView with lazy loading, I load 40 lines at a time.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Type ItemValue (value As String)
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private clv1 As CustomListView
Private clv_label1 As Label
Private clv_label2 As Label
Private clv_button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
Log("The time now is: " & DateTime.Time(DateTime.Now))
For i = 1 To 10000
Dim iv As ItemValue
iv.Initialize
clv1.Add(Create_Item( i , iv ), iv)
Next
Log("The time now is: " & DateTime.Time(DateTime.Now))
End Sub
Private Sub Create_Item (lv1 As String,iv As ItemValue) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0,0,0,80%x,120dip)
p.LoadLayout("ItemLayout")
clv_label1.Text = lv1
clv_label2.Text = lv1
iv.value = lv1
Return p
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub clv1_ItemClick (Index As Int, Value As Object)
Dim iv As ItemValue = clv1.GetValue(Index)
Log(iv.value)
Log("Int " & Index & ", Object "& Value)
ToastMessageShow(clv_label1.Text,False)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
clv1.AddTextItem("4Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" & CRLF & "Eeee", "e")
For i = 1 To 5000
clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 60dip), $"Item #${i}"$)
Next
End Sub