Android Question ListView with Images and text

Declan

Well-Known Member
Licensed User
Longtime User
I have looked at numerous examples of loading images into ListView, but all seem to pertain to downloading from Http sites.
I am successfully downloading a BLOB from my remote MySQL database and am able to display the image in a ImageView and text in a Label.
I use this code from my JobDone sub:
B4X:
                If result.Tag = "select_img" Then
                    For Each records() As Object In result.Rows
                        Dim Buffer() As Byte
                        Dim HeaderTxt As String
                        Buffer = records(result.Columns.Get("img02"))
                        HeaderTxt = records(result.Columns.Get("TxtHeader"))
                        Dim InputStream1 As InputStream
                        InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
                        Dim Bitmap1 As Bitmap
                        Bitmap1.Initialize2(InputStream1)
                        InputStream1.Close
                        ImageView1.SetBackgroundImage(Bitmap1)
                        Label1.Text = HeaderTxt
                    Next
                End If
How can I place the Image and the Text into a ListView control?
I could have numerous records and need to display in a ListView with the image on the left and the text on the right of the image.
The user can then scroll through the list of images and text
 

MohammadNew

Active Member
Licensed User
Longtime User
B4X:
If result.Tag = "select_img" Then
For Each records() As Object In result.Rows
Dim Buffer() As Byte
Dim HeaderTxt As String
Buffer = records(result.Columns.Get("img02"))
HeaderTxt = records(result.Columns.Get("TxtHeader"))
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1)
InputStream1.Close

ListView1.AddTwoLinesAndBitmap(HeaderTxt), "" , Bitmap1)
Next
End If
 
Last edited:
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
many thanks, that works a treat.
The image is very small, how do I increase the size of the image?
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
many thanks, that works a treat.
The image is very small, how do I increase the size of the image?

you can change value as you like

B4X:
ListView1.TwoLinesAndBitmap.ImageView.SetLayout(0dip, 0dip, 150dip, 150dip)
        ListView1.TwoLinesAndBitmap.ItemHeight = 150dip
 
Last edited:
Upvote 0
Top