Hi
I have list view - reading from database
and I added tag value for each line
how do I read the line tag after I click certain line?
sub listview_ItemClick (Position As Int, Value As Object)
dim myitem as string
myitem = value <--- This will contain the databasecolumn2 value..
end sub
Cursor = SQL1.ExecQuery("SELECT * FROM CustomerList")
If Cursor.RowCount > 0 Then
For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
ListView_CustomerList.SingleLineLayout.Label.Gravity = Gravity.RIGHT
ListView_CustomerList.AddSingleLine (Cursor.GetString("Price") & " ")
ListView_CustomerList.Tag = (Cursor.GetString("Makat"))
Next
End If
Cursor.Close
I need the tag information not to be show in the table
but I need it's value to pass for other tables queries
Cursor = SQL1.ExecQuery("SELECT * FROM CustomerList")
If Cursor.RowCount > 0 Then
ListView_CustomerList.SingleLineLayout.Label.Gravity = Gravity.RIGHT
For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
ListView_CustomerList.AddSingleLine2(Cursor.GetString("Price") & " ",Cursor.GetString("Makat"))
Next
End If
Cursor.Close
Your code will not work:
- ListView_CustomerList.SingleLineLayout.Label.Gravi ty = Gravity.RIGHT
It os not necessary to put this line in the For/Next loop, putting it outsides of the loop is enough, because it defines the gravity for all entries.
- ListView_CustomerList.Tag, is the Tag of the ListView and not for each entry!
I would suggest you following code:
In this case the value in a ListView_ItemClick event will be Cursor.GetString("Makat")B4X:Cursor = SQL1.ExecQuery("SELECT * FROM CustomerList") If Cursor.RowCount > 0 Then ListView_CustomerList.SingleLineLayout.Label.Gravity = Gravity.RIGHT For i = 0 To Cursor.RowCount - 1 Cursor.Position = i ListView_CustomerList.AddSingleLine2(Cursor.GetString("Price") & " ",Cursor.GetString("Makat")) Next End If Cursor.Close
Best regards.
It will not be costly in system resources.
It's not a special property, it's just the normal separator for parameters in a method call. AddSingleLine2 takes two parameters.Are there other characters that have special properties like that?