B4J Question How update any loaded image in listview rows.

Ivan Henderson

New Member
Licensed User
How do you change the custom listview image via click event. used your code but seems to only update the image in the last customlistview row added. Would like to update any listview row item by button press. with new image file. Code works but only updates the very last row image item.
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Take a look at the CustomListView example,

the answer is here:
I have added some comments which were not in the original.

B4X:
Sub Button1_Click

  ' This line take the button that has been clicked on and works out which CLV item it belongs to.
    Dim index As Int = clv2.GetItemFromView(Sender)

 'This line then gets the base panel upon which the layout was loaded
    Dim pnl As B4XView = clv2.GetPanel(index)

' Get the actuals views (Note: This is hardcoded, it may be better to use GetAllViewsRecursive to find the view.
    Dim lbl As B4XView = pnl.GetView(0)
    Dim chk As B4XView = pnl.GetView(2)

  ' Make the changes
    lbl.Text = "Clicked!"
    'Msgbox("Item value: " & clv2.GetValue(index) & CRLF & "Check value: " & chk.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
 
Upvote 0
Top