Hello,
Currently what I'm trying to do is display my database in a listview using this tutorial: http://www.b4x.com/forum/basic4android-getting-started-tutorials/8339-connect-android-mysql-database-tutorial.html and then displaying all of my entries with their id and their first name. This works perfectly fine, but when you press an item in the list, I want to display their first name and their surname in two seperate labels. I've managed a way to this, but it's extremely slow. What is a more efficient way on doing this?
Thanks in advance,
SCIS.
Currently what I'm trying to do is display my database in a listview using this tutorial: http://www.b4x.com/forum/basic4android-getting-started-tutorials/8339-connect-android-mysql-database-tutorial.html and then displaying all of my entries with their id and their first name. This works perfectly fine, but when you press an item in the list, I want to display their first name and their surname in two seperate labels. I've managed a way to this, but it's extremely slow. What is a more efficient way on doing this?
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
Dim tl As TwoLines
tl = Value
intListviewID = tl.First
lblCountry.Text = tl.Second
ExecuteRemoteQuery("SELECT familienaam FROM users WHERE id='" & tl.First & "'", USER_VOORNAAM)
End Sub
B4X:
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case USERS_LIST
Dim USERS As List
USERS = parser.NextArray 'returns a list with maps
For i = 0 To USERS.Size - 1
Dim m As Map
m = USERS.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
Dim tl As TwoLines
tl.First = m.Get("id")
tl.Second = m.Get("voornaam")
ListView1.AddTwoLines2(tl.First, tl.Second, tl)
Next
Case USER_VOORNAAM 'THIS PART RIGHT HERE
Dim l As List
l = parser.NextArray
If l.Size = 0 Then
lblPopulation.Text = "N/A"
Else
i = 0
Do Until i = l.Size
Dim m As Map
Dim id As Int
m = l.Get(i)
id = m.Get("id")
If id = intListviewID Then
lblPopulation.Text = m.Get("familienaam")
End If
i = i + 1
Loop
End If
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Thanks in advance,
SCIS.