Hello,
I have a customView (Dados) with two pictures and 2 labels
How do I change the Image in a given cell ?
B4X:
Dim Bm1 As Bitmap = LoadBitmap(File.DirAssets,CurrLng.ToLowerCase & ".png")
Dim Bm2 As Bitmap = LoadBitmap(File.DirAssets,"caller_off.png")
Dados.Add(CreateListItem(Bm1,Bm2,"Pedido : " & NumPed & " - Pessoas : " & NumPax, DataPed & " - " & HoraPed,Dados.AsView.Width, 70dip), 70dip, "")
B4X:
Sub CreateListItem(Imagem1 As Bitmap, Imagem2 As Bitmap ,Text1 As String, Text2 As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.SetLayout(0, 0, Width, Height)
p.LoadLayout("CellItem")
lbl1.Text = Text1
lbl2.Text = Text2
ImgView.Bitmap = Imagem1
ImgView.Width = Height - 5
ImgView.Height = Height - 5
RingView.Bitmap = Imagem2
RingView.Height = Height - 5
RingView.Width = Height - 5
Return p
End Sub
B4X:
Sub Dados_ItemClick (Index As Int, Value As Object)
Dim pnl As Panel = Dados.GetPanel(Index)
Dim l1 As Label = pnl.GetView(2)
Dim LocSep As Int = sF.InString(l1.text," - Pessoas : ")
Dim NumPed As String = sF.Mid(l1.text,10,LocSep-9)
Dim CurLng As String = CheckLngRec(NumPed)
BroadcastNumber( "S" & NumPed & ":" & CurLng )
Dim Bm2 As Bitmap = LoadBitmap(File.DirAssets,"caller_on.png")
' The layout 'cellItem' has 2 Imageviews and 2 labels
'I want to Load a Bitmap (Bm2) to the second ImageView
End Sub
There are all kinds of way to find the correct view. The simplest is to check the index of ImgView in the views tree in the designer.
You can then get it with:
B4X:
Dim p As Panel = CLV.GetPanel(Index)
Dim iv As ImageView = p.GetView(<index here>)