Android Question populating a listview 2linesbitmap from db on a for..loop

threadw

Member
Licensed User
Longtime User
hello,

here is my problem, i have a database of some products with the name of the picture in one of the columns from there i construct my url to work with either httputils2 or picasso and using addtwolinesandbitmap2 i put the rest, the thing is that when the for loop starts i either get all the text right but no pictures thats putting the listview add command inside the loop or i get all the images but only the last text on the loop for all of item.

here is my code using picasso:
Sub DBload
LVDb.Clear'need to clear the list
cursor1 = SQL1.ExecQuery("SELECT * FROM Productos limit 5")
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
imageURL="http://datcolt.net16.net/rdc_images/" & cursor1.GetString("PhotoLink")
imageURL=imageURL.Replace(" ","%20")
textreferencia = cursor1.GetString("Referencia")
textPrecioventa = cursor1.GetString("PrecioVenta")
textid = cursor1.GetString("ProductoID")
Dim Picasso1 As Picasso
Picasso1.Initialize
Dim Target1 As DefaultTarget
Target1.Initialize("Target1", "Bitmap")
Picasso1.LoadUrl(imageURL).Fetch(Target1)

ProductoImage.InitializeMutable(10dip,10dip)
LVDb.AddTwoLinesAndBitmap2(textreferencia, "$" & textPrecioventa,ProductoImage ,textid)
Next

End Sub
Sub Target1_Success(Bitmap1 As Bitmap, Tag As Object)
Log("Target1_Success Tag="&Tag)
If Tag="Bitmap" Then
' do something with the Bitmap
ProductoImage.Initialize3 (Bitmap1)
End If
End Sub

and here is the same code using httputils2:

Sub DBload
LVDb.Clear'need to clear the list
cursor1 = SQL1.ExecQuery("SELECT * FROM Productos limit 2")
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
imageURL="http://datcolt.net16.net/rdc_images/" & cursor1.GetString("PhotoLink")
imageURL=imageURL.Replace(" ","%20")
textreferencia = cursor1.GetString("Referencia")
textPrecioventa = cursor1.GetString("PrecioVenta")
textid = cursor1.GetString("ProductoID")
Dim job1 As HttpJob
job1.Initialize("job1",Me)
job1.Download (imageURL)
ProductoImage.InitializeMutable(10dip,10dip)
If job1.success=True Then
ProductoImage=job1.GetBitmap
LVDb.AddTwoLinesAndBitmap2(textreferencia, "$" & textPrecioventa,ProductoImage ,textid)
End If


Next

End Sub

Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
'show the downloaded image
Try
ProductoImage=Job.GetBitmap

Catch LastException
Msgbox(LastException.Message,"")
End Try

Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub

please share some light,
thanks
 
Top