It can be useful when you load the layout multiple times, for example with CLV.
You can then do something like:
B4X:
Dim p As B4XView = clv.GetPanel(x)
p.GetView(8).Text = "abc" 'txtStagione
There are of course, other ways to organize the references and I would say that if your layout becomes complicated then this method is probably not the best one. It will break when you add or remove a view.
It can be useful when you load the layout multiple times, for example with CLV.
You can then do something like:
B4X:
Dim p As B4XView = clv.GetPanel(x)
p.GetView(8).Text = "abc" 'txtStagione
There are of course, other ways to organize the references and I would say that if your layout becomes complicated then this method is probably not the best one. It will break when you add or remove a view.
Hi Erel,
i develop some business management software app.
The best for me would be
B4X:
Panel.GetView_byName("lblCustomer").Text = "My customer name"
For this i use Ultimate List View library
to set the bound from view and data i write some code as this code example...
B4X:
Sub ULV_RowContentFiller(RowID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
'this is called from each record in UltimateList
Dim mpRow As Map = ULV_List.Get(RowID)
Dim lblCodArt As Label = LayoutPanel.GetView(1) ' cod articolo
Dim lblDescrizione As Label = LayoutPanel.GetView(4) ' descr articolo
Dim lblTaglia As Label = LayoutPanel.GetView(2)
Dim fldTaglia As Label = LayoutPanel.GetView(3) ' taglia
Dim lblQtaDaPrelevare As Label = LayoutPanel.GetView(5)
Dim fldQtaDaPrelevare As Label = LayoutPanel.GetView(6) ' qta
Dim lblQtaPrelevata As Label = LayoutPanel.GetView(7)
Dim fldQtaPrelevata As Label = LayoutPanel.GetView(8) ' qta
'Dim etichettaColore As Label = LayoutPanel.GetView(9)
Dim lblColore As Label = LayoutPanel.GetView(10)
'Dim lblbox As Label = LayoutPanel.GetView(11)
Dim fldbox As Label = LayoutPanel.GetView(12)
Dim fldMP As Label = LayoutPanel.GetView(14)
Dim fldUbicazione As Label = LayoutPanel.GetView(16)
fldUbicazione.Text = mpRow.Get("ubicazione")
fldbox.Text = mpRow.Get("barcode")
fldbox.TextSize = 12
fldbox.Visible = True
lblCodArt.Text = mpRow.Get("cod_articolo")
lblDescrizione.Text = mpRow.Get("articolo")
fldMP.Text = mpRow.Get("materiale")
fldQtaDaPrelevare.Text = mpRow.Get("qta")
fldQtaPrelevata.Text = mpRow.Get("qtaprelevata")
LayoutPanel.Tag = mpRow.Get("barcode")
For i = 1 To 1000
Dim p As B4XView = XUI.CreateView("")
p.SetLayoutAnimated(...)
p.LoadLayout(...)
Dim ViewsMap As Map
ViewsMap.Initialize
For Each v As B4XView In p.GetAllViewsRecursive
If v.Tag <> "" Then ViewsMap.Put(v.Tag, v) 'set the tag of the views that you want to access, in the designer.
Next
p.Tag = ViewsMap
Next
GetViewFromPanel(CLV.GetPanel(50), "lblCustomer").Text = "abcde"
Sub GetViewFromPanel(p As B4XView, Name As String) As B4XView
Dim m As Map = p.Tag
Return m.Get(Name)
End Sub