I thought I was there, but now I think that what I was looking for does not exist
B4X:
'This does not work!!
Sub fillpagefromdb
Dim Cursor1 As Cursor,name As String,value As String,o As View
Cursor1 = db.sql1.ExecQuery("SELECT * FROM table1")
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
name=Cursor1.GetString("name")
value=Cursor1.GetString("data")
o=GetObjectFromTag(name)
If (o) Then o.text=value
Next
Cursor1.Close
End Sub
Sub GetObjectFromTag(a As String) As View
Dim o As View
o=Null
For i = 0 To Activity.NumberOfViews - 1
If Activity.GetView(i).Tag = a Then
o=Activity.GetView(i)
Continue
End If
Next
Return o
End Sub
What does not work ?
This line looks strange to me :
B4X:
If (o) Then o.text=value
Perhaps I'm wrong, never tried this.
But without knowing what is not working I don't want to spend much time to guess what could be wrong.
Don't you have a small test project to test it ?
This obviously does work, but somehow I find it less appealing
B4X:
Sub fillPageFromDb
Dim Cursor1 As Cursor,name As String,data As String
Cursor1 = db.sql1.ExecQuery("SELECT * FROM table1")
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
name=Cursor1.GetString("name")
data=Cursor1.GetString("data")
Select name
Case "label1"
Label1.Text=data
Case "titel"
Label2.text=data
End Select
Next
Cursor1.Close
End Sub
I think the map in Erel's solution needs to be maintained manually, ie. there is no way to generate that map?!
What does not work ?
This line looks strange to me :
B4X:
If (o) Then o.text=value
Perhaps I'm wrong, never tried this.
But without knowing what is not working I don't want to spend much time to guess what could be wrong.
Don't you have a small test project to test it ?...
All this looks quite complicated to me.
What kind of data do you have in your database?
When I use a database I know what data is in there and design the interface according to tha data.
But it seems I am missing something here.