dbutils listview question

Daren463

Member
Licensed User
Longtime User
Below is my code. Can someone point me to an example of how to deal with the value of ListView4_ItemClick? I get [Ljava.lang.String;@410e3468. I should be getting “T7”. I have tried several different ways I found on the forms but I probably didn't do something right.

Sub Button4_Click
'Select Play List
Dim qry As String

ListView4.Clear
qry = "SELECT DISTINCT List FROM Playlist"
DBUtils.ExecuteListView(sql1,qry,Null,0,ListView4,False)

End Sub

Sub ListView4_ItemClick (Position As Int, Value As Object)
Label2.Text = Value
End Sub
 

klaus

Expert
Licensed User
Longtime User
Try the code below:
B4X:
Sub ListView4_ItemClick (Position As Int, Value As Object)
    Dim cols() As String
    cols = Value
    Label2.Text = cols(0)
End Sub
DBUtils.ExecuteListView uses ListView1.AddSingleLine2(Cols(0), Cols) where cols is an array of strings with one value in this case.

You could also change the DBUtils routine like below:
B4X:
Sub ExecuteListView(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, ListView1 As ListView, _
    TwoLines As Boolean)
    ListView1.Clear
    Dim Table As List
    Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
    Dim Cols() As String
    For i = 0 To Table.Size - 1
        Cols = Table.Get(i)
        If TwoLines Then
            ListView1.AddTwoLines2(Cols(0), Cols(1), Cols)
        Else
'            ListView1.AddSingleLine2(Cols(0), Cols)
            ListView1.AddSingleLine(Cols(0))
        End If
    Next
End Sub
The commented line is the original one.

Best regards.
 
Upvote 0
Top