iOS Question CustomListView.GetValue

BjoernB

Member
Licensed User
Hello everyone,

my code won't work and i have no idea why actually o_O
maybe you can help me

i have a few rows of data shown in a customListView, filled with ListView.add(data, index)

now i wanna put it back into a list to work with the selected data, but this won't work as i thought

My ListView is called EdText and i want to put the clicked row in a list (tmp)

code on ItemClick is:

B4X:
Sub EdText_ItemClick (Index As Int, Value As Object)
    Dim tmp As List

    tmp.Initialize
   
    tmp.Add(EdText.GetValue(Index))

I just checked again,
Index and Value both just have "1" in it. the row i clicked in the list contains a number, a time and 2 names.
how do i get these infos?
 
Last edited:

BjoernB

Member
Licensed User
Post the code that fills the list.

Hi Erel,

i tried again, actually Index and Object aren't always 1 but the row i clicked.

here's the code that fills it:
B4X:
Do While i < Main.PersLst.Size
    Dim s as String
    Dim lst as List
    Dim mnr As Int
    Dim arbstart As String
    Dim vorname As String
    Dim name As String
    Dim i As Int
    
    s = Main.PersLst.Get(i) 'actual Row of recieved list from Server'
        
    lst = util.StrTok(s, ";")
    mnr = util.atoi(lst.Get(1))   
    arbstart = lst.Get(2)
    vorname = lst.Get(3)       
    name = lst.Get(4)
        
    EdText.AddTextItem(mnr & " - " & util.zt2str(arbstart) & " - " & vorname & " " & name, i+1)
    
    i = i + 1
Loop
 
Upvote 0

BjoernB

Member
Licensed User
There is no reason to use the Value to store the list index. This is actually a mistake as the index can change if you later insert or remove items. Simply use the Index parameter.
sorry, my english ain't that good, maybe i simply don't understand what you're telling me here

in filling the ListView, it expects an index and throws an error if i don't give it one.
in reading from the list onclick, both, the index and the value, just contain the row number i clicked.

what can i do to get the actual text?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
in filling the ListView, it expects an index and throws an error if i don't give it one.
No. You can pass anything you like for the "Value" parameter.

what can i do to get the actual text?
There are many options. A simple one is to pass the text as the "value".
 
Upvote 0
Top