Android Question xCustomlistview Library and Button Click

Cornelius Smit

Member
Licensed User
Good day
I need help please I have a custom listview (library) and use a layout for my image and a button !! How do i capture the correct button click event
Thank you in advance
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello @Cornelius Smit, welcome to this great community.
Everything that you need to know can be fund in the first post right HERE, just download the code and study it carefully, it really is straight forward to follow.

Wait a minute, have you looked at this sub in the example provided?

I've added a log line in the code below, it will help you out a bit to see what is happening when you click a button in Erel's example.
B4X:
Sub Button1_Click
    Dim index As Int = clv2.GetItemFromView(Sender)
    Dim pnl As B4XView = clv2.GetPanel(index)
    Dim lbl As B4XView = pnl.GetView(0)
    Dim chk As B4XView = pnl.GetView(2)
    lbl.Text = "Clicked!"
    'Msgbox("Item value: " & clv2.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")

    Dim chk1 As B4XView = pnl.GetView(2)
    Log("Checked = " & chk1.Checked)

    Dim checkedItems As List
    checkedItems.Initialize
    For i = 0 To clv2.GetSize - 1
        Dim p As B4XView = clv2.GetPanel(i)
        Dim chk As B4XView = p.GetView(2)
        If chk.Checked Then
            checkedItems.Add(clv2.GetValue(i))
        End If
    Next
    Log("Checked items: " & checkedItems)
End Sub
 
Last edited:
Upvote 0
Top