I have a question regarding the possibility of looping intialization of views. In other words, i have a bunch of textfields and labels that i want to send to a function to initialize them all such as this:
Replace:
B4X:
Private txtbox as TextField
txtbox.initialize("")
txtbox.font=createnew2(...,14)
Mainpanel.addview(txtbox,20,20...)
By:
B4X:
Private txtbox as TextField
buildElement(txtbox)
Sub buildElement(txtbox as (?), ini as string, fontsize as int, left, top...)
txtbox.initialize(ini)
txtbox.font=createnew2(...,fontsize)
Mainpanel.addview(txtbox,left,top...)
End Sub
Is that possible? or do i have to go through each of my 120 textboxes and labels to set the initialization and the font size...?
It is possible. The type should match the object type.
You can also find all the relevant views and set their font property:
B4X:
For Each v As View In Page1.RootPanel.GetAllViewsRecursive
If v Is Label Then
Dim lbl As Label = v
lbl.Font = ...
Else if v Is TextField Then
Dim tf As TextField = v
tf.Font = ...
Else if v Is TextView Then
Dim tv As TextView = v
tv.Font = ...
End If
Next