Android Question [solved]Why XCustomListView display incorrect , CustomListview display right

Maodge

Member
Licensed User
hi,
i'm confuse of XCustomListView and CustomListview.
in project using CustomListview, add items code is
B4X:
    For i = 0 To 29
        Dim colors1 As Int
        Dim csb As CSBuilder
        colors1 = Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255))
        csb.Initialize.Color(colors1).Append("# ITEM : ").Append(i).Append(" !").PopAll
        xcl1.Add(CreatelistItem(csb, xcl1.AsView.Width,50dip),50dip,i)

    Next
this can display correct.

in project using XCustomListview, add items code is
B4X:
    For i = 0 To 29
        Dim colors1 As Int
        Dim csb As CSBuilder
        colors1 = Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255))
        csb.Initialize.Color(colors1).Append("# ITEM : ").Append(i).Append(" !").PopAll
        xcl1.Add(CreatelistItem(csb, xcl1.AsView.Width,50dip),i)

    Next
and this display nothing.

and CreatelistItem code here
B4X:
Sub CreatelistItem(Text As  CSBuilder , Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.RGB(48,48,48)
   
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lbl.Text = Text
    lbl.TextSize = 18
    lbl.Color = Colors.Black
    p.AddView(lbl, 2dip, 2dip, Width, Height - 4dip) 'view #2

    Return p
   
End Sub
so why XCustomListView display incorrect?
Thanks customlistview.png tst xcustlist.png
 
Top