OK so I have a much stripped down version that exhibits bad behavior. It isn't exactly the same behavior as I get in my main app originally but it is still wrong.
In my original problem it always returned the correct position but the wrong value and the value changed. In this example it always returns the correct position and always returns the Value for the last item I loaded in the listView which is still bad behavior.
I zipped the complete example to attach but it is too large to attach. I will send it to you directly if you can tell me how. I have attached a png of the screenshot of the listview sp you can see the colors loaded correctly.
I tried it logging Value directly, assigning Value to lvd and declaring lvd2 as ListViewData locally and assigning Value to that. The overall problem is that it returns correct Position but incorrect value for the Position selected.
If I walk down the listView clicking each item in turn, the log output is as follows:
Position = 0
Selected = [FirstRow=Green, SecondRow=Info about Green, Pic=(Bitmap): 200x192, IsInitialized=false]
Position = 1
Selected = [FirstRow=Green, SecondRow=Info about Green, Pic=(Bitmap): 200x192, IsInitialized=false]
Position = 2
Selected = [FirstRow=Green, SecondRow=Info about Green, Pic=(Bitmap): 200x192, IsInitialized=false]
Position = 3
Selected = [FirstRow=Green, SecondRow=Info about Green, Pic=(Bitmap): 200x192, IsInitialized=false]
Position = 4
Selected = [FirstRow=Green, SecondRow=Info about Green, Pic=(Bitmap): 200x192, IsInitialized=false]
The app code is listed here:
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim listPlan As ListView
Type ListViewData (FirstRow As String, SecondRow As String, Pic As Bitmap)
Dim lvd As ListViewData
Dim bmPlanned As Bitmap
bmPlanned.Initialize(File.DirAssets, "bmPlanned.jpg")
listPlan.Initialize("")
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim Lb As Label
Activity.LoadLayout("plan")
listPlan.BringToFront
listPlan.TwoLinesAndBitmap.SecondLabel.Visible = True
listPlan.TwoLinesAndBitmap.Label.Visible = True
listPlan.ScrollingBackgroundColor = Colors.Transparent
Lb = listPlan.TwoLinesAndBitmap.Label
Lb.Textsize = 16
Lb.TextColor = Colors.Black
Lb.Color = Colors.White
lvd.FirstRow = "Red"
lvd.SecondRow = "Info about Red"
lvd.Pic = bmPlanned
listPlan.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Pic, lvd)
lvd.FirstRow = "Blue"
lvd.SecondRow = "Info about Blue"
lvd.Pic = bmPlanned
listPlan.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Pic, lvd)
lvd.FirstRow = "Yellow"
lvd.SecondRow = "Info about Yellow"
lvd.Pic = bmPlanned
listPlan.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Pic, lvd)
lvd.FirstRow = "Orange"
lvd.SecondRow = "Info about Orange"
lvd.Pic = bmPlanned
listPlan.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Pic, lvd)
lvd.FirstRow = "Green"
lvd.SecondRow = "Info about Green"
lvd.Pic = bmPlanned
listPlan.AddTwoLinesAndBitmap2(lvd.FirstRow, lvd.SecondRow, lvd.Pic, lvd)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub listPlan_ItemClick(Position As Int, Value As Object)
Log("Position = " & Position)
Log("Selected = " & Value)
End Sub