Hi,
I have a CustomListView with in every item, an imageview, and 3 labels. (See the attached view)
I have to load items from a database on a server, and I use JobDone.
In the database there is the data for labels and th URL for image to load into the Imageview
(URL_Vignette)
.
I Know to load an image from server to a Page.
I Know and arrive to load the labels to CustomListView items but I do not arrive to load Image in the same item.
Below my code when I load the same image from File.DirAssets. But I have to load a different image from the database to every item. Can someone help me?
Thank you very much.
I have a CustomListView with in every item, an imageview, and 3 labels. (See the attached view)
I have to load items from a database on a server, and I use JobDone.
In the database there is the data for labels and th URL for image to load into the Imageview
(URL_Vignette)
.
I Know to load an image from server to a Page.
I Know and arrive to load the labels to CustomListView items but I do not arrive to load Image in the same item.
Below my code when I load the same image from File.DirAssets. But I have to load a different image from the database to every item. Can someone help me?
Thank you very much.
B4X:
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
'XXXXXXXXX LISTING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Case LISTING_LIST
Dim RES As String
RES = Job.GetString
Dim parser As JSONParser
parser.Initialize(RES)
Dim Affiche_list As List
Affiche_list = parser.NextArray 'returns a list with maps
For i = 0 To Affiche_list.Size - 1
Dim sb As StringBuilder
Dim M As Map
M = Affiche_list.Get(i)
Dim Civilite, Prenom, Ville, Zip, Telephone, sexe, URL_Vignette As String
Dim Longi, Lati As Double
Dim annee As Long
Civilite = M.Get("civilite")
Prenom = M.Get("prenom")
Ville = M.Get("ville")
Zip = M.Get("zip")
annee = M.Get("annee")
sexe = M.Get("sexe")
URL_Vignette = M.Get("img")
Telephone = M.Get("phone1")
Longi = M.Get("longitude")
Lati = M.Get("latitude")
'----- Pour le GPS ------------------------------------
Dim distance As Double
Dim TheDistance, MyDistance, Carte_V As String
Dim TheLongitude, TheLatitude As Double
TheLongitude = Longi
TheLatitude = Lati
Dim Location1, Location2 As Location
Location1.Initialize2(LatitudeMe, LongitudeMe)
Location2.Initialize2(TheLatitude, TheLongitude)
distance = Location1.DistanceTo(Location2)'Distance en metres entre location1 et location2
distance = distance / 1000
'distance = Round2 (distance,1)'Dans B4A
TheDistance = NumberFormat(distance,0,1)'Dans B4i
Carte_V = Civilite & " " & Prenom & ", " & annee
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'HOW TO ADD HERE CODE FOR THE VIGNETTE IMAGE
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Dim Rien = "" As String
Dim MyVignette As String
MyVignette = "kinda.png"
If GeoLoc = True Then
MyDistance = "A " & TheDistance & " km" & ", " & Ville
clvListing.Add(CreateListItem3(Carte_V, MyDistance, Ville, MyVignette,clvListing.AsView.Width, 55dip), 70dip, M)
Else
clvListing.Add(CreateListItem3(Prenom, Ville,Rien, MyVignette, clvListing.AsView.Width, 55dip), 70dip, M)
End If
Next
Case "JobImgEcran"
'show the downloaded image
ImgEcran.Bitmap = Job.GetBitmap
End Select
Else
Log("Error: " & Job.ErrorMessage)
hd.ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
B4X:
Sub CreateListItem3(Text1 As String, Text2 As String, Text3 As String,Vignette As String, Width As Int, Height As Int) As Panel
'Routine pour placer 3 labels et une vignette dans l'item de la customListView
Dim P As Panel
P.Initialize("")
P.Color = Colors.White
'Dim ImgVignette As ImageView
Dim lbl1, lbl2, lbl3 As Label
lbl1.Initialize("lbl1")
lbl1.TextAlignment = lbl1.ALIGNMENT_LEFT
'lbl1.Color =Colors.Gray
lbl1.Text = Text1
lbl1.Font = Font.CreateNew(22)
lbl2.Initialize("lbl2")
lbl2.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl2.Multiline= True
lbl2.Text = Text2
lbl2.Font = Font.CreateNew(16)
lbl3.Initialize("lbl3")
lbl3.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl3.Multiline= True
lbl3.Text = Text3
lbl3.Font = Font.CreateNew(16)
'JobImgEcran.Initialize("JobImgEcran", Me)
'JobImgEcran.Download(MyURL_Image)
Dim ImgVignette As ImageView
ImgVignette.Initialize("ImgVignette")
Dim Repertoire = File.DirAssets As String
ImgVignette.Bitmap = LoadBitmap(Repertoire , Vignette)
P.AddView(ImgVignette, 2dip, 5dip, 18%x, 18%x )
P.AddView(lbl1, 5dip + 20%x, 0dip, 75%x, Height/2-5dip )
P.AddView(lbl2, 5dip + 20%x, lbl1.Height, 75%x, Height/2)
P.AddView(lbl3, 5dip + 20%x, (lbl1.Height +lbl2.Height)-5dip, 75%x, Height/2)
Return P
End Sub