Android Question [Resolved]Using xCustomListView to set a ListView

ALBRECHT

Active Member
Licensed User
Hello,


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)
'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
 

DonManfred

Expert
Licensed User
Longtime User
This does not work with a listview.
Use xCustomListview instead.
 
Upvote 0

ALBRECHT

Active Member
Licensed User
Please,

to see better how it works with a list of : text + online images sources

is there an simple example of xCustomListView using.

Sorry, but there I am lagging a little

(with 9.3 version, xCustomListView is in standard library)

Michel
 
Upvote 0

ALBRECHT

Active Member
Licensed User
I understand your advice to use the new library xCustomListView, but after viewing the tutorial video which have local pictures files to be inserted into the list, I try to have that process :

B4X:
Example
For i =1 to n
Image = "URL link/" & i & ". Jpeg" 
If not exist image already dnl in the local folder then
    Dnl the image into the local folder
End if
Next

Then after, I could use xCustomListView as seen with the tutorial

Michel
 
Upvote 0

ALBRECHT

Active Member
Licensed User
ok i have just finished the work with merging of both library : customview and ImageDownloader. and it works fine.

but i would open now a new post about the ImageDownloader library using.

thanks for all
 
Upvote 0
Top