Android Question listview itemclick returning wrong value but correct position

nemethv

Member
Licensed User
Longtime User
Hi

I have a simple listview that has the AddTwoLinesANDBitmap2 setup, values get added, everything is good.
When I try to use the LineList_ItemClick (Position As Int, Value As Object), the position that gets returned is correct (ie 0 for the first, 1 for the second etc) but the Value is always that of the last element in the list.
1590862851851.png


See on the screenshot. For position 0 it should be the Edgware Road one, not Belsize Pk.
What am I missing?
 

nemethv

Member
Licensed User
Longtime User
Posting the relevant code?
B4X:
Do While SQLRS.NextRow
            ....
            
  lvd2.FirstRow = lvStationName
  lvd2.SecondRow = SQLRS.GetString("LineName") & " - "& SQLRS.GetString("DirectionName")
  LineList.AddTwoLinesANDBitmap2(lvd2.FirstRow, lvd2.SecondRow, CurrentLineLogo, lvd2)
                            
Loop

...
B4X:
Sub LineList_ItemClick (Position As Int, Value As Object)
    Dim lvd2 As ListViewData
    lvd2 = Value
...
 
Upvote 0

nemethv

Member
Licensed User
Longtime User
Found the issue.
The lvd2 wasn't re-dimmed within the loop.
Should have been:
B4X:
Do While SQLRS.NextRow
            
            Dim lvd2 As ListViewData
            lvd2.Initialize
            ...
 
Upvote 0
Top