Android Question Downloader Image to ListView

Alisson

Active Member
Licensed User
I use the code:

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Bitmap, Bitmap1, Bitmap2,Bitmap3,Bitmap4,Bitmap5,Bitmap6,Bitmap7,Bitmap8, Bitmap9, Bitmap10,Bitmap11,Bitmap12,Bitmap13,Bitmap14,Bitmap15,Bitmap16, Bitmap17, Bitmap18,Bitmap19,Bitmap20,Bitmap21,Bitmap22 As Bitmap
    Dim listed As ListView
    Dim res As String
    Dim chanels As HttpJob
    Dim ret As String
    Dim parser As JSONParser
    Dim m As Map
    Dim links As Map
End Sub

Sub Activity_Create(FirstTime As Boolean)

chanels.Initialize("Chanel", Me)
    chanels.Download2("http://addres/file.php", _
      Array As String("imei", imei))
   
   
' Crea listed (ListView)
    listed.Initialize("listed")
    listed.Color=Colors.Black
    listed.TwoLinesLayout.ItemHeight = 50dip
    listed.TwoLinesLayout.Label.TextSize = 10dip
    listed.TwoLinesLayout.Label.TextColor = Colors.Blue
    listed.TwoLinesLayout.Label.Gravity = Gravity.CENTER
    listed.FastScrollEnabled=True
    listed.clear
   
       
       
    Activity.AddView(listed, 0dip, 40dip, 100%x, 420dip)
    Activity.AddMenuItem("Volver","boton_menu")


End Sub


Sub Activity_Resume
    CallSub(ImageDownloader, "ActivityIsPaused")
End Sub


Sub JobDone (Job As HttpJob)
  If Job.Success = True Then
      Select Job.JobName
       
    Case "Chanel"
        Dim i As Int    
     ret = Job.GetString
     parser.Initialize(ret)       
    Dim root As List = parser.NextArray
    For Each colroot As Map In root
        i = i + 1  
    Dim name As String = colroot.Get("name")
    Dim content As String = colroot.Get("content")
    Dim image As String = colroot.Get("image")
    Bitmap1.Initialize(File.DirAssets, img)
    links.Initialize
    links.Put(Bitmap1, "http://image.com/image.png")
    CallSubDelayed2(ImageDownloader, "Download", links)
    listado.AddTwoLinesAndBitmap(name, content,Bitmap1) 
    Next
    End Select
  Else
      ToastMessageShow("Error: " & Job.ErrorMessage, True)
  End If
  Job.Release
End Sub


Is there a way to add images in Listview ?
On the line:

B4X:
Bitmap1.Initialize(File.DirAssets, img)

Lets just open directory with images stored on the phone.

Any idea?
 

Alisson

Active Member
Licensed User
Erel thanks very much!!!
Erel, the text of list is possible change color to black?
I can change just the background list.

Thanks!!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…