Android Question DBUtils.ExecuteListView wrong value on listview1_ itemclick

grant1842

Active Member
Licensed User
Longtime User
I am using
B4X:
DBUtils.ExecuteListView(SQL,"Select Radio.* From Radio",Null ,0,ListView1,False)
to populate listview1 and not addtwolines .
I am geting the wronge value on item click.
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
   
Label1.Text = ListView1.GetItem(Position)
Log(ListView1.GetItem(Position))
End Sub
or
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
   
Label1.Text = Value
End Sub

here is the text that shows up on label1.text
[Ljava.lang.String;@42144e10
Why am I getting this instead of the text in the listview1 ?
Thanks
 

klaus

Expert
Licensed User
Longtime User
If you look at the inline help:
'Executes the query and fills the ListView with the value.
'If TwoLines is true then the first column is mapped to the first line and the second column is mapped
'to the second line.
'In both cases the value set to the row is the array with all the records values.

The return value when you click on an item is an array with all record values.
To get a given value you need to extract it from the array.
 
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
I used this encase anyone else needs to know.
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    Dim a() As String
    a = Value
    Log(a(0))
    radio = a(0)
    StartActivity("instruction")
End Sub
 
Upvote 0

riano_defretes

Member
Licensed User
hi, i'm newbie here..
i try to load sms in liesview object, can you help me how to load them..

my code is

Sub ceksms
Dim Smsmessage1, Smsmessage2 As SmsMessages

Dim liste As List
Dim liste1 As List
Dim Sms As Sms

liste.Initialize
liste = Smsmessage1.GetAll


For i = 0 To liste.Size -1

Dim Sms As Sms
Sms = liste.Get(i)

Log (Sms.Address)
Log (Sms.Body)
Log ("-------")
Next

Dim mylist As List
mylist.Initialize

For i = 0 To liste.Size -1 'tes
mylist.Add(liste.Get(i))
Next

For i = 0 To mylist.Size -1
listview1.AddSingleLine2("code here")
Next
End Sub
 
Upvote 0
Top