ListView.GetItem

cstangor

Member
Licensed User
Longtime User
Is there any way to get the text of the item if the return value has also been set?
 

mc73

Well-Known Member
Licensed User
Longtime User
Perhaps I don't get your question. You mean this?
B4X:
ListView1.GetItem (Position)
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
I think he means if he sets the listview item #1 to "Beans & Cornbread" and sets the response answer to "meal#1", the click event will return "meal#1". He is asking is there a way to also have it return "Beans & Cornbread".

The few times I have used it, I have always return all data required in the Response string and if needed used a delimiter so I could split the answer when I needed to like:

"Beans & Cornbread ~ meal#1"
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I think he means if he sets the listview item #1 to "Beans & Cornbread" and sets the response answer to "meal#1", the click event will return "meal#1". He is asking is there a way to also have it return "Beans & Cornbread".

The few times I have used it, I have always return all data required in the Response string and if needed used a delimiter so I could split the answer when I needed to like:

"Beans & Cornbread ~ meal#1"

This is the reason I didn't get the question. When you assign a new value instead of the default set text, you do it in order to perform an action using this new value, at least so I understand. Now, in case you truly need still the initial text value, sure you can use a delimited string :)

B4X:
Sub Process_Globals
End Sub
Sub Globals
    Dim lstv As ListView 
End Sub
Sub Activity_Create(FirstTime As Boolean)
    lstv.Initialize ("lstv")
    Dim s As String 
    Dim v As String 
    For k=0 To 9
        s="this is item " & k
        v="item " & k
        lstv.AddSingleLine2 (s,s & "//" & v)
    Next
    Activity.AddView (lstv,0,0,100%x,100%y)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub lstv_ItemClick (Position As Int, Value As Object)
    Dim ar() As String 
    ar=Regex.Split ("//",Value)
    Msgbox(ar(0),ar(1))
End Sub
 
Upvote 0

cstangor

Member
Licensed User
Longtime User
Thanks to you all for debugging my cryptic message. Exactly what I needed to know (put everything in the 2nd field and split it as needed).

Happy weekend all!
 
Upvote 0
Top