Android Question Add layout to listview

invocker

Active Member
I want to add a layout with button to listview this is my code
B4X:
Private Sub Button1_Click
    Dim p As LayConta
    p.Initialize
    B4XPages.AddPage("lay1",p)
    B4XPages.ShowPage("lay1")
    p.Btnmsg.Tag="Hellow B4A"
    '********************************************
    Dim addtolv As B4XView
    addtolv = xui.CreatePanel("")
    addtolv.Color=Colors.Transparent
    addtolv.SetLayoutAnimated(100,0,0,Root.Width,Root.Height/3 )
    '****************************************************************************
    Dim lv1 As lv
    lv1.Initialize
    B4XPages.AddPage("lv1",lv1)
    '     B4XPages.ShowPage("lv1")
    '****************************************************************************
    Dim lv1 As lv = B4XPages.GetPage("lv1")
    lv1.Initialize
    addtolv.LoadLayout("Lay")
    lv1.CustomListView1.Add(addtolv,"")
    
End Sub

project added
 

Attachments

  • Project.zip
    16.8 KB · Views: 132

Mahares

Expert
Licensed User
Longtime User
I want to add a layout with button to listview this is my code
This is how I would have done it:
'B4XMainPage Code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    Dim p As LayConta
    p.Initialize
    B4XPages.AddPage("lay1",p)
    
    Dim lv1 As lv
    lv1.Initialize
    B4XPages.AddPage("lv1",lv1)
    
End Sub

Private Sub Button1_Click
    B4XPages.ShowPage("lay1")
    B4XPages.ShowPage("lv1")
End Sub

'lv class module code:
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Dim CustomListView1 As CustomListView
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Dim addtolv As B4XView
    addtolv = xui.CreatePanel("")
    addtolv.Color=Colors.Transparent
    addtolv.SetLayoutAnimated(100,0,0,Root.Width,Root.Height/3 )
    Root.LoadLayout("lvLay")
    CustomListView1.Add(addtolv,"")
End Sub

Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Log("I have no value   " & Index)    
End Sub

'LayConta class module code:
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Dim Btnmsg As B4XView
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Lay")
    Btnmsg.Tag="Hellow B4A"
    Btnmsg.text="Hellow B4A"
    Btnmsg.Color=xui.Color_Magenta    
End Sub

public Sub Btnmsg_Click
    ToastMessageShow(Btnmsg.Tag,False)
End Sub

Use xCustomListView
He is using xClv
 
Upvote 1
Top