Android Question How to retrieve item values from CustomListView

Patrick Clark

Active Member
Licensed User
I have created a list of panels with values but I do not understand how to get the values back when they (or the whole item) is clicked.

The layout includes Label1, Label2, Label3, Label4, Label5, EditText, Button

I need to be able to change the background colour of Label4 and the text of Label5 and the Colour of Button.

The actions should be fired with Lable4 or Label5 are tapped, EditText is Changed or Button is clicked.

I can get the index of the item containg the item that was touched/clicked but I don't know how to access the individual items.

Thanks
 

Patrick Clark

Active Member
Licensed User
Thank Erel

I do this

B4X:
Sub btnChangeSealColour_Click
    Dim item As Int = clvSeals.GetItemFromView(Sender)
    Dim p As B4XView = clvSeals.GetPanel(item)
    Msgbox(p.GetView(0).Text,"")
End Sub

and I get
java.lang.RuntimeException: Object should first be initialized (View).


Also: How do I know which is item(0) item(1) etc. I thought it was the order in the designer but that seams not to be
 
Last edited:
Upvote 0

Patrick Clark

Active Member
Licensed User
Thanks I only use msgbox for debugging because I want the code to stop.

BUT: even with Log i still get the same exception

UPDATE: It works ok in my little test app. The difference is that each list item contains a panel with the controls as children of the panel. So I have put all of the controls directly on the activity and it is working now. BUT should I be able to nest controls or not?
 
Last edited:
Upvote 0
Top