I try to learn something from Erels CLVExpandable . But I already have heavy problems in understanding the scope of the variables
code reduced to minimum for poiting to the problem
The Layout "Item" contains a Label named "lblTitle"
How is it possible, that this lblTitle.Text becomes a (different) part of the 20 differend ps? lblTitle is only one global variable. Until now I thought 20 labels also need 20 corresponding variables.
How does p (inside the CreateItem() ) know that the code line with lblTitle.Text is it's lblTitle.Text?
I would have understood something like p.lblTitle.Text. But where is the relation between the loaded Layout and the global variable? And what happens with lblTitle after the 20 asignments?
Would this also work with 20 buttons?
code reduced to minimum for poiting to the problem
B4X:
Sub Process_Globals
...
Private xui As XUI
Private lblTitle As B4XView
End Sub
Sub AppStart...
For i = 1 To 20
Dim p As B4XView = CreateItem( "Item #" & i)
clv1.Add(p,...)
Next
End Sub
Sub CreateItem( Title As String) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.LoadLayout("Item")
lblTitle.Text = Title
Return p
End Sub
The Layout "Item" contains a Label named "lblTitle"
How is it possible, that this lblTitle.Text becomes a (different) part of the 20 differend ps? lblTitle is only one global variable. Until now I thought 20 labels also need 20 corresponding variables.
How does p (inside the CreateItem() ) know that the code line with lblTitle.Text is it's lblTitle.Text?
I would have understood something like p.lblTitle.Text. But where is the relation between the loaded Layout and the global variable? And what happens with lblTitle after the 20 asignments?
Would this also work with 20 buttons?
Last edited: