Android Question CustomListView

RUNO

Active Member
Licensed User
Longtime User
I want download image from web but if I put this code in createitem function
B4X: Copy
Dim j As HttpJob
            j.Initialize("", Me)
            j.Download("https://xxxxx.000webhostapp.com/picf/g.png")
            Wait For (j) JobDone(j As HttpJob)
            If j.Success Then
            ''''''''''
I got this error
Resumable subs return type must be ResumableSub (or none).

Can anyone help me?
 
 
Upvote 0

In createitem function return panel not value.
How I fixed?
 
Upvote 0
My project is paused.
I want to download data from the database and view them with pictures using customlistview, does anyone help?
 
Upvote 0
Hi

Thanks, but my images from website not from device.
Where I put the code of downloading images?
If I put inside CreateItem function, I got mistak like first post
 
Upvote 0
This might give you an Idea ... The code below has not been tested !

adaption of this code here .. https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-For.79345/#content
... and using the xCustomListview example.

Code: Copy
Sub DownloadImage(Link As String)
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(Link)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        clv.Add(CreateListItem(j.GetBitmap, clv.AsView.Width, 130dip), "MyReturnValue")
    End If
    j.Release
End Sub

Sub CreateListItem(bmp As Bitmap, Width As Int, Height As Int) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("CellItem")
    ImageView1.Bitmap = bmp
    Return p
End Sub


Edit ... I presume you have an ImageView (ImageView1) included in your CLV RowItems layout.
 
Last edited:
Upvote 0
This might give you an Idea ... The code below has not been tested !

adaption of this code here .. https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-For.79345/#content
... and using the xCustomListview example.

Code: Copy
Sub DownloadImage(Link As String)
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(Link)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        clv.Add(CreateListItem(j.GetBitmap, clv.AsView.Width, 130dip), "MyReturnValue")
    End If
    j.Release
End Sub

Sub CreateListItem(bmp As Bitmap, Width As Int, Height As Int) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("CellItem")
    ImageView1.Bitmap = bmp
    Return p
End Sub


Edit ... I presume you have an ImageView (ImageView1) included in your CLV RowItems layout.

Thanks @mangojack
 
Upvote 0
Back
Top