B4J Question Get views by code

jGubern

Member
Licensed User
Longtime User
I would like to replace the text of several Textfield with code.
How can I access these views from code?
I guess something like
MainForm.RootPane ........
But I am not able to get it. (rookie)
any suggestions?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are all kinds of ways.
Example of clearing all TextFields:
B4X:
'Add reference to XUI
Dim parent As B4XView = MainForm.RootPane
 For Each x As B4XView In parent.GetAllViewsRecursive
   If x Is TextField Then x.Text = ""
 Next
In many cases it is better to create an array or list with the relevant views:
B4X:
Dim Fields As List = Array(TextField1, TextField2, ...)

'later
Dim tf As TextField = Fields.Get(1) 'second one
tf.Text = "abc"
 
Upvote 0
Top