Hi,
I am using the CustomListView and I am trying to work out how to edit an item once it has been added.
Below is the code I am using to create the list.
What I want to do is change the image of an item in the list.
Any ideas on how to edit only 1 item in list based on the lbl1.Text value?
For Example, if lbl1.Text = "Item: 3" then change img1 to another image.
I am using the CustomListView and I am trying to work out how to edit an item once it has been added.
Below is the code I am using to create the list.
What I want to do is change the image of an item in the list.
Any ideas on how to edit only 1 item in list based on the lbl1.Text value?
For Example, if lbl1.Text = "Item: 3" then change img1 to another image.
B4X:
Sub CreateList
clv1.Initialize(Me, "clv1", 100%X-20dip,True)
pg1.RootPanel.AddView(clv1.AsView, 10dip, 75dip, 100%x - 20dip, 100%y)
For i = 1 To 200
clv1.Add(CreateListItem("Item " & (i), i), 50dip, i)
Next
End If
End Sub
Sub CreateListItem(Text As String, itemNum As String) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.White
Dim img1 As ImageView ' M1 Logo
img1.Initialize("img1")
img1.Bitmap = LoadBitmap(File.DirAssets, "green_icon1.png")
Dim lbl As Label
lbl.Initialize("lbl")
lbl.TextAlignment = lbl.ALIGNMENT_LEFT
lbl.Text = Text
lbl.Font = Font.CreateNew(16)
Dim lbl1 As Label
lbl1.Initialize("lbl1")
lbl1.TextAlignment = lbl.ALIGNMENT_LEFT
lbl1.Text = "Item: " & itemNum
lbl1.Font = Font.CreateNew(13)
lbl1.TextColor = Colors.Gray
p.AddView(img1, 7dip, 15dip, 22dip, 22dip) 'view #0
p.AddView(lbl, 40dip, -5dip, 100%x - 90dip, 50dip) 'view #1
p.AddView(lbl1, 40dip, 13dip, 100%x - 90dip, 50dip) 'view #2
Return p
End Sub