process global and listview

Sw Controll Group Kft

Member
Licensed User
Longtime User
Can I have some help to this situation?

I have a main activity with a result:
B4X:
Sub Process_Globals
   Dim person As person1  
End Sub

Sub Globals
   Type person1 (id As String,reg As String,name As String)
End Sub

I call the another activity where I fill a listview from sqlite:

B4X:
Sub Button1_Click

   Dim Cursor As Cursor
   Dim tt As person1
   ProgressDialogShow("reading")
   listview1.Clear

   Cursor = Main.SQL1.ExecQuery("select * from paciens where nev like '" & Edittext1.Text & "%' order by name;")
   For i = 0 To Cursor.RowCount - 1
         Cursor.Position = i
        tt.id=Cursor.GetInt("_id")
    tt.name=Cursor.GetString("name")
    tt.reg=Cursor.GetString("reg")
    ListView1.AddTwoLines2 (tt.name,tt.reg,tt)
    Next
    Cursor.Close
    ProgressDialogHide
End Sub

And I read the selected listitem:

B4X:
Sub listview1_ItemClick (Position As Int, Value As Object)
   Main.person=value    'always last item!!
End Sub

The Main.person is the last listitem in the listview always. Why?

Thx!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…