Hello,
Im using that kind of code to read a json file and display it on listvew :
That works great, but to insert an image (PictureId field), i have to replace le line :
by somethink like that , to add the online image:
'the third field PictureId could be used like that for the Image Link :
'https://www.materiel-medical-a-domicile.com/content/images/0002428_0.jpeg
And if possible : to download the picture only if it dont already exists on the device (for a faster process)
I have tried several methods, but I do not know how to nest a jobdone in another
thank you kindly to give me some ideas for that add.
Michel
Im using that kind of code to read a json file and display it on listvew :
B4X:
Sub Process_Globals
Private ServerUrl As String = "https://www.materiel-medical-a-domicile.com/Asp/ListCatJson.asp"
End Sub
Sub Globals
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Matmed")
ListView1.SingleLineLayout.Label.TextSize = 14
Dim job As HttpJob
job.Initialize("Job1", Me)
job.PostString(ServerUrl, "SELECT Id, Name, PictureId FROM Table_1")
End Sub
Sub JobDone (Job As HttpJob)
If Job.Success = True Then
Dim res As String = Job.GetString2("UTF-8") 'to be sure
Dim parser As JSONParser
parser.Initialize(res)
Dim rows As List
rows = parser.NextArray
Dim LibTxt As String
For i = 0 To rows.Size - 1
Dim m As Map
m = rows.Get(i)
LibTxt = m.Get("Libelle") & " : " & i
ListView1.AddSingleLine(LibTxt)
Next
Else
Log ("Db Error !!")
End If
Job.Release
End Sub
That works great, but to insert an image (PictureId field), i have to replace le line :
B4X:
ListView1.AddSingleLine(LibTxt)
by somethink like that , to add the online image:
B4X:
ListView1.AddTwoLinesAndBitmap(LibTxt, "line 2" , Job.GetBitmap)
'https://www.materiel-medical-a-domicile.com/content/images/0002428_0.jpeg
And if possible : to download the picture only if it dont already exists on the device (for a faster process)
I have tried several methods, but I do not know how to nest a jobdone in another
thank you kindly to give me some ideas for that add.
Michel