1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question [Resolved]Using xCustomListView to set a ListView

Discussion in 'Android Questions' started by ALBRECHT, Jul 14, 2019.

  1. ALBRECHT

    ALBRECHT Active Member Licensed User

    Hello,


    Im using that kind of code to read a json file and display it on listvew :

    Code:
    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 :
    Code:
    ListView1.AddSingleLine(LibTxt)
    by somethink like that , to add the online image:
    Code:
    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
     
  2. DonManfred

    DonManfred Expert Licensed User

    This does not work with a listview.
    Use xCustomListview instead.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Peter Simpson likes this.
  4. ALBRECHT

    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
     
  5. ALBRECHT

    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 :

    Code:
    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
     
  6. ALBRECHT

    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice