Android Question Get value from two lines Listview

Mostez

Well-Known Member
Licensed User
Longtime User
I have two lines list view with no bitmaps, I used this code to get value of two lines, but I get an error, what is the correct method to get values of two lines?
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.shell.Shell$RemoteObject

B4X:
Type TwoLines (FirsText As String , SecondText As String)

B4X:
Sub lstRowBrowser_ItemLongClick (Index As Int, Value As Object)
    
    Dim TwoStrings As TwoLines
    TwoStrings.Initialize
    TwoStrings = Value ' value returns value of first line only
    Log(TwoStrings.FirsText) ' error
    Log(TwoStrings.SecondText)
 

klaus

Expert
Licensed User
Longtime User
When you fill the ListView you should use AddTwoLines2(Text1 As CharSequence, Text2 As CharSequence, ReturnValue As Object)
You can define any object for the ReturnValue.
With AddTwoLines, you get only the first line as the return value.
Example:
B4X:
Private twl As TwoLines
twl.Initialize
twl.FirstText = "Line 1"
twl.SecondText = "Line 2"
lstRowBrowser.AddTwoLines2(twl.FirstText, twl.SecondText, twl)

Sub lstRowBrowser_ItemLongClick (Index As Int, Value As Object)
    Dim TwoStrings As TwoLines
    TwoStrings.Initialize
    TwoStrings = Value ' value returns value of first line only
 
Upvote 0
Top