Android Question adding xCustomListView by code

aligol

Member
I tried to add xCustomListView by code to activity by code but a yellow warning appeared that type do not match(warning#22).

How should I add CLVby only by codes?

B4X:
     dim xlv as CustomListView
    xlv.Initialize(Me,"xlv")
    Activity.AddView(xlv,0,0,Activity.Width,Activity.Height)
 

Alexander Stolte

Expert
Licensed User
Longtime User
How should I add CLVby only by codes?
Create a new form and put the xclv on it. Then load the form to a panel, done.
 
Upvote 1

aligol

Member
Create a new form and put the xclv on it. Then load the form to a panel, done.
thanks for your response.
pardon me for my ignorance
But does it possible to create an object of Xclv by code not designer(form) and put that on a panel or activity? If the answer is no,can you please explain why?


B4X:
    Dim clv As CustomListView
    Dim pnl As Panel

    clv.Initialize(Me,"clv")
    pnl.Initialize("")
   
    Activity.AddView(pnl,0,0,Activity.Width,Activity.Height)
    pnl.AddView(clv,0,0,pnl.Width,pnl.Height)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
But does it possible to create an object of Xclv by code not designer(form) and put that on a panel or activity? If the answer is no,can you please explain why?
It works, but it is very messy.
I do this exactly the same way in my custom views where I use them.

B4X:
Private Sub ini_xclv

    Dim tmplbl As Label
    tmplbl.Initialize("")
 
    Dim tmpmap As Map
    tmpmap.Initialize
    tmpmap.Put("DividerColor",0x00FFFFFF)
    tmpmap.Put("DividerHeight",0)
    tmpmap.Put("PressedColor",0x00FFFFFF)
    tmpmap.Put("InsertAnimationDuration",0)
    tmpmap.Put("ListOrientation",m_Orientation)
    tmpmap.Put("ShowScrollBar",False)
    
    xclv_main.Initialize(Me,"xclv_main")
    xclv_main.DesignerCreateView(mBase,tmplbl,tmpmap)
    
End Sub
 
Upvote 0
Top