Based on this post https://www.b4x.com/android/forum/threads/cards-list-with-customlistview.87720/#content, is it possible to retrieves or changes the value from a label control of a cardview list? If my label is named Label2, how can I change the text?
For example:
I'd like to change the text of a 6th cardview..
Any suggestions?
Thanx!
For example:
B4X:
Public Sub lista()
Dim Table1 As List
Try
Table1 = DBUtils.ExecuteMemoryTable(Starter.SQL, "SELECT c, datadoc, imp, num FROM S", _
Null, 0)
Dim Cols() As String
Dim bitmaps As List = Array("hand.png", "calc.png")
For i = 0 To Table1.Size - 1
tmpval = Table1
Cols = Table1.Get(i)
Log(Cols(1) & " " & Cols(0) & " " & Cols(2))
Dim content As String = $"Some text here.."$
'CARDLV1.Add(CreateItem(CARDLV1.AsView.Width, $"Cod. Cliente: #${Cols(0)} - ${Starter.SaldiRagsoc}"$, bitmaps.Get(0), content), "")
CARDLV1.Add(CreateItem(CARDLV1.AsView.Width, $"Cod. Cliente: #${Cols(0)}"$, bitmaps.Get(0), content, Cols(2), Cols(0)), "")
Next
Catch
Log(LastException.Message)
End Try
End Sub
Private Sub CreateItem(Width As Int, Title As String, Image As String, Content As String, importo As String, index As Int) As Panel
Dim p As B4XView = xui.CreatePanel("")
Dim height As Int = 280dip
If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 310dip
p.SetLayoutAnimated(0, 0, 0, Width, height)
p.LoadLayout("Card1")
lblTitle.Text = Title
lblContent.Text = Content
'SetColorStateList(lblAction1, xui.Color_LightGray, lblAction1.TextColor)
SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
'SetTextList(imp, Label2.Text)
ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, Image, ImageView1.Width, ImageView1.Height, True))
imp.Text = 0
Label2.Text = "Importo € : " & importo
tmpimp = importo.Replace(",",".")
Label1.Text = tmpimp
Label2.Tag = index
Log(Label2.Tag)
Return p
End Sub
Sub imp_TextChanged (Old As String, New As String)
Dim Cols() As String
Dim totimp As Double
Dim index As Int = CARDLV1.GetItemFromView(Sender)
If Old <> New Then
Cols = tmpval.Get(index)
Try
totimp = CDbl(Cols(2).Replace(",",".")) - New
Catch
New = 0
totimp = CDbl(Cols(2).Replace(",",".")) - New
End Try
Label2.Text = "Importo da saldare € : " & totimp '<----- text to change
End If
End Sub
Any suggestions?
Thanx!