Android Question Problem with ListView.AddSingleLine2

Holger Brauer

Member
Licensed User
Hello,
perhaps someone can help me.

I create a ListView named LV_events:
LV_events.AddSingleLine2(TEMPname, TEMPuserid & TEMPadress).
All Strings have fixed lenghts.

On a click I want to extract TEMPuserid and TEMPadress from the Value

Sub LV_events_ItemClick (Position As Int, Value As Object)
Dim getstring As String
getstring = "" & Value

but after that, getstring is not a string. I want to use sf.left(getstring ...) to extract parts of the 'value as object'

Thank you
 

DonManfred

Expert
Licensed User
Longtime User
You are not setting any value in your
B4X:
LV_events.AddSingleLine2(TEMPname, TEMPuserid & TEMPadress)

B4X:
    For i = 0 To 2
        Dim value As Map
        value.Initialize
        value.Put("line1",TEMPname)
        value.Put("line2",TEMPuserid & TEMPadress)
        LV_events.AddTwoLines2(value.Get("line1"), value.Get("line2"), value)
    Next

B4X:
Sub lv_ItemClick (Position As Int, Value As Object)
    Dim retmap As Map
    retmap = Value
    Log("Item at Pos "&Position&" Clicked...")
    Log("ItemInfos:")
    Log("line 1 = "&retmap.Get("line1"))
    Log("line 2 = "&retmap.Get("line2"))
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Sorry. I did not read your post right.
B4X:
LV_events.AddSingleLine2(TEMPname, TEMPuserid & TEMPadress).
Will add TEMPname into the listview and
TEMPuserid&TEMPadress into the value. As one concenated string

B4X:
Sub LV_events_ItemClick (Position As Int, Value As Object)
Dim getstring As String = Value
should give you this string.

Maybe it is just another issue you have here? Maybe i misinterpreted the problem; or i dont see it

but after that, getstring is not a string

What is getstring in your app? I mean; what does
B4X:
log(getstring)
put into the log?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Another approach you can adapt to your code

B4X:
        Dim value As Map
        value.Initialize
        value.Put("line1",TEMPname)
        value.Put("userID",123)
        value.Put("Adress","My secret address")
        value.Put("Tel","0815")
        lv.AddSingleLine2(value.Get("line1"), value)
 
Upvote 0
Top