B4J Question Custom List View AddTextItem read/get text at index? [Solved]

Paul_

Member
Licensed User
The Custom List View AddTextItem is a very useful method as the panel/label is resized automatically to fit the text but how do you read read/get the text stored at an index?

B4X:
Dim myText="ABCDEFG" As String

For line=0 To 30
  xCLV1.AddTextItem(myText,"")
Next

Private Sub xCLV1_ItemClick (Index As Int, Value As Object)
    Log("Index: "&Index&" Value: "&Value)
End Sub

A simple hack solution is to add the same text as the item value:

B4X:
For line=0 To 30
  xCLV1.AddTextItem(myText,myText)
Next

But how can the original text at the xCLV index be read/get directly from the panel/label?

Is there a click event for the xCLV text item label?

Am I missing something simple?
 

PaulMeuris

Active Member
Licensed User
Your simple hack works but it is better to use the line integer as the value.
The CustomListView has a panel for each item and on that panel it has a label (view number 0).
The text from that label is the item text.
B4X:
    For line=0 To 30
        xCLV1.AddTextItem(myText,line)
    Next

Private Sub xCLV1_ItemClick (Index As Int, Value As Object)
    Log("Index: "&Index&" Value: "&Value)
    Log(xCLV1.GetPanel(Index).GetView(0).Text)
End Sub
 
Upvote 0

Paul_

Member
Licensed User
Your simple hack works but it is better to use the line integer as the value.
The CustomListView has a panel for each item and on that panel it has a label (view number 0).
The text from that label is the item text.
B4X:
    For line=0 To 30
        xCLV1.AddTextItem(myText,line)
    Next

Private Sub xCLV1_ItemClick (Index As Int, Value As Object)
    Log("Index: "&Index&" Value: "&Value)
    Log(xCLV1.GetPanel(Index).GetView(0).Text)
End Sub

Excellent, thank you. That's exactly what I was looking for, a way to access the label directly ?
 
Upvote 0
Top