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

Discussion in 'Android Questions' started by Maodge, Jul 12, 2018.

  1. Maodge

    Maodge Member Licensed User

    hi,
    i'm confuse of XCustomListView and CustomListview.
    in project using CustomListview, add items code is
    Code:
    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
    Code:
    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
    Code:
    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, 
    2dip2dip, Width, Height - 4dip'view #2

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

    Erel Administrator Staff Member Licensed User

    You are missing:
    Code:
    p.SetLayout(00, Width, Height)
     
    Peter Simpson likes this.
  3. Maodge

    Maodge Member Licensed User

    Thanks. my program is OK now
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice