Android Question ListView Separator

Declan

Well-Known Member
Licensed User
Longtime User
I am populating a ListView from a SQLite table.
All OK and images and text loads.
Is there a way I can place a "separator line" between the items?
My Code:
B4X:
            For i=0 To Curs.RowCount-1
                Curs.Position=i
                        Dim Buffer() As Byte
                        Dim PartnersHeader As String
                        Dim PartnerText As String
                        Buffer = Curs.GetBlob("partnerimage")
                        PartnersHeader = Curs.GetString("partnername")
                        PartnerText = Curs.GetString("partnertext")
                        Dim InputStream1 As InputStream
                        InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
                        Dim Bitmap1 As Bitmap
                        Bitmap1.Initialize2(InputStream1)
                        InputStream1.Close
                        lvPartners.TwoLinesAndBitmap.ItemHeight = 120dip
                        lvPartners.TwoLinesAndBitmap.ImageView.Height = 120dip
                        lvPartners.TwoLinesAndBitmap.ImageView.Width = 120dip
                        lvPartners.TwoLinesAndBitmap.Label.TextColor=Colors.Black
                        lvPartners.TwoLinesAndBitmap.Label.TextSize = 20
                        lvPartners.TwoLinesAndBitmap.Label.Left = (((lvPartners.TwoLinesAndBitmap.ImageView.Left) + (lvPartners.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
                        lvPartners.AddTwoLinesAndBitmap(("      " & CRLF & PartnersHeader), "                         " &  PartnerText , Bitmap1)
                    Next
 

DonManfred

Expert
Licensed User
Longtime User
- Do the layout-setting before the loop... You only need to do it once.
- Use onelinelayout for a spacer

B4X:
    lvPartners.SingleLineLayout.ItemHeight = 1dip
    lvPartners.SingleLineLayout.Label.Color = Colors.Red
    lvPartners.TwoLinesAndBitmap.ItemHeight = 120dip
    lvPartners.TwoLinesAndBitmap.ImageView.Height = 120dip
    lvPartners.TwoLinesAndBitmap.ImageView.Width = 120dip
    lvPartners.TwoLinesAndBitmap.Label.TextColor=Colors.Black
    lvPartners.TwoLinesAndBitmap.Label.TextSize = 20
    lvPartners.TwoLinesAndBitmap.Label.Left = (((lvPartners.TwoLinesAndBitmap.ImageView.Left) + (lvPartners.TwoLinesAndBitmap.ImageView.Width)) + 5dip)
    For i=0 To Curs.RowCount-1
        Curs.Position=i
        Dim Buffer() As Byte
        Dim PartnersHeader As String
        Dim PartnerText As String
        Buffer = Curs.GetBlob("partnerimage")
        PartnersHeader = Curs.GetString("partnername")
        PartnerText = Curs.GetString("partnertext")
        Dim InputStream1 As InputStream
        InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        Dim Bitmap1 As Bitmap
        Bitmap1.Initialize2(InputStream1)
        InputStream1.Close
        lvPartners.AddTwoLinesAndBitmap(("      " & CRLF & PartnersHeader), "                         " &  PartnerText , Bitmap1)
        lvPartners.AddSingleLine("")
    Next
 
Upvote 0
Top