Hi all,now i using a customlistview and i need to load image to imageview from my server.
But i try using this code,but it seen like can't load image to the right imageview.
But i try using this code,but it seen like can't load image to the right imageview.
B4X:
Sub Display_Image
Dim links As Map
If Load_Last_Image_Index < ListView_Order.GetSize Then
For i = Load_Last_Image_Index To ListView_Order.GetSize -1
Dim pnl As Panel = ListView_Order.GetPanel(i)
Dim Get_Path As Label = pnl.GetView(7)
Dim Get_Image_View As ImageView = pnl.GetView(2)
If Get_Path.Text <> "" Then
links.Initialize
links.Put(Get_Image_View, "Server_Path" & Get_Path.Text & ".jpg")
End If
Next
CallSubDelayed2(ImageDownloader, "Download", links)
End If
Load_Last_Image_Index = ListView_Order.GetSize
End Sub
B4X:
Sub Download (ImageViewsMap As Map)
For i = 0 To ImageViewsMap.Size - 1
tasks.Put(ImageViewsMap.GetKeyAt(i), ImageViewsMap.GetValueAt(i))
Dim link As String = ImageViewsMap.GetValueAt(i)
ongoingTasks.Put(link, "")
Dim j As HttpJob
j.Initialize(link, Me)
j.Download(link)
Next
End Sub
B4X:
Sub JobDone(Job As HttpJob)
ongoingTasks.Remove(Job.JobName)
If Job.Success Then
Dim bmp As Bitmap = Job.GetBitmap
cache.Put(Job.JobName, bmp)
If tasks.IsInitialized Then
For i = 0 To tasks.Size - 1
Dim link As String = tasks.GetValueAt(i)
If link = Job.JobName Then
Dim iv As ImageView = tasks.GetKeyAt(i)
iv.SetBackgroundImage(bmp)
End If
Next
End If
Else
Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
End If
Job.Release
End Sub