Please help, I am trying to insert images into a CustomListView, the images are downloaded from internet, the code works half brings me updated list but only the last image of CustomListView.(see img below)
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Private lst_tragos = "lst_tragos", fot_marca = "fot_marca", fot_pro = "fot_pro"
Dim lv As CustomListView
Type treslineas (First As String, Second As String, Tercero As String)
Dim temp As Boolean
Private pg As Page
Private Label1 As Label
Private ncarrito As Label
Private carrito As ImageView
Private foto_marca As ImageView
Dim imgmarca As String
'Dim b As Bitmap
Dim im As ImageView
End Sub
Public Sub Show
If pg.IsInitialized = False Then
pg.Initialize("pg")
pg.RootPanel.LoadLayout("carta")
End If
Main.NavControl.ShowPage(pg)
im.Initialize("")
llenar_lista
End Sub
Sub cargar_img(fot As String)
des_img("http://www.xxxxxx.com/app/exxxxs/images/mxxx/" & fot, fot_marca)
End Sub
Sub llenar_lista
ExecuteRemoteQuery("select * from inventario where categoria = '"&Main.categoria&"' and marca = '"&Main.marca&"'", lst_tragos)
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxxx.com/xxxx_xxx.php", Query)
End Sub
Sub des_img(url As String, JobName As String)
Dim job1 As HttpJob
job1.Initialize(JobName, Me)
job1.Download(url)
End Sub
Sub JobDone(Job As HttpJob)
lv.Initialize(Me, "lv", 100%X)
pg.RootPanel.AddView(lv.AsView, 0, 0, 100%x, 150%y)
lv.SetSize(Label1.Width, 150%y)
lv.AsView.Left = 0%x
lv.AsView.Top = 0%y + foto_marca.Top + foto_marca.Height + 3dip
lv.AsView.Color = Colors.ARGB(25,0,0,0)
'ProgressDialogHide
If Job.Success Then
'Log("Response from server: " & res)
Select Job.JobName
'***********************************************
Case lst_tragos
Dim res As String
res = Job.GetString
Dim parser As JSONParser
parser.Initialize(res)
Dim l2 As List
lv.Clear
l2 = parser.NextArray
If l2.Size = 0 Then
Msgbox("No se encontraron registros", False)
Else
Log (l2.Size)
For i = 0 To l2.Size - 1
Dim tl As treslineas
Dim m As Map
m = l2.Get(i)
tl.First = m.Get("nombre")
tl.Second = m.Get("foto")
tl.Tercero = m.Get("descripcion")& Chr(13) & Chr(10) & " Valor: $" & m.Get("valor")
imgmarca = m.Get("foto_marca")
lv.Add(CreateListItem(tl.First,tl.Second , 120%x, 70dip), 70dip, "Item")
Next
'Msgbox(imgmarca,"")
cargar_img(imgmarca)
End If
'****************************************************
Case fot_marca
foto_marca.Bitmap=Job.GetBitmap
'************************************************
Case fot_pro
im.Bitmap = Job.GetBitmap
End Select
Else
Msgbox("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub CreateListItem(Text As String,foto As String, Width As Int, Height As Int) As Panel
Dim m2 As Map
m2.Initialize
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
'Dim b As Bitmap
'b.Initialize(File.DirAssets,"flecha.png")
Dim im As ImageView
im.Initialize("")
'im.Bitmap = b
Dim lbl As Label
lbl.Initialize("lbl")
lbl.TextAlignment = lbl.ALIGNMENT_LEFT
lbl.Text = Text
lbl.Font = Font.CreateNew(13)
lbl.TextColor = Colors.White
p.AddView(lbl, Height+5dip,0,Width*0.8,Height)
des_img("http://www.xxxxxx.com/axxxxp/exxxxxes/images/xxxx/" & foto, fot_pro)
p.AddView(im, 0,0,Height,Height)
Return p
End Sub