Hello, this is a simple example I made to mimic ListView.GetItem behaviour:
At runtime on log window the result is:
** Activity (main) Create, isFirst = true **
lv.size=2
lv.GetItem=[b=b_row_2, a=a_row_2, IsInitialized=true]
row number 0 ,stringA=a_row_2 ,stringB=b_row_2
lv.GetItem=[b=b_row_2, a=a_row_2, IsInitialized=true]
row number 1 ,stringA=a_row_2 ,stringB=b_row_2
** Activity (main) Resume **
There is nowere the 1st row (row_1) of listview.
Can you see where the code error is? :sign0144:
B4X:
Sub Process_Globals
Type twostrings (a As String , b As String)
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If firsttime Then
Dim lv As ListView
lv.Initialize ("")
Dim ts As twostrings
ts.Initialize
'add two rows
ts.a = "a_row_1"
ts.b = "b_row_1"
lv.AddTwoLines2(ts.a ,ts.b , ts)
ts.a = "a_row_2"
ts.b = "b_row_2"
lv.AddTwoLines2(ts.a ,ts.b , ts)
'read listview row count
Log ("lv.size=" & lv.Size)
'read listview row data
i = 0
Do While i < lv.Size
Log ("lv.GetItem=" & lv.GetItem(i))
Dim ts As twostrings
ts.Initialize
ts = lv.GetItem(i)
Log ("row number " & i & _
" ,stringA=" & (ts.a) & _
" ,stringB=" & (ts.b))
i = i + 1
Loop
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
** Activity (main) Create, isFirst = true **
lv.size=2
lv.GetItem=[b=b_row_2, a=a_row_2, IsInitialized=true]
row number 0 ,stringA=a_row_2 ,stringB=b_row_2
lv.GetItem=[b=b_row_2, a=a_row_2, IsInitialized=true]
row number 1 ,stringA=a_row_2 ,stringB=b_row_2
** Activity (main) Resume **
There is nowere the 1st row (row_1) of listview.
Can you see where the code error is? :sign0144: