Referencing elements in a Layout in code ...

darkuni

Member
Licensed User
Longtime User
When you visually create a layout with an EditText view, load it into the activity - I notice you cannot reference it directly:

EditText1.text

... simply doesn't show up as being available.

How do you "link" the layout views proper to your activity code?

Most of the demos I've seen appear to revolve around creating views programmatically, not accessing the from a layout created by the designer.

Thanks :)
 

klaus

Expert
Licensed User
Longtime User
You need to have following line in the Globals routine.
B4X:
Dim EditText1 As EditText
This can be done with the GenerateMembers function in the Designer. Look at chapter 8.2.1 GenerateMembers in the Beginner's Guide.

Best regards.
 
Upvote 0

darkuni

Member
Licensed User
Longtime User
Right right .. I knew about Generate Members.

I guess the concept of "declaring" it in the designer then still having to put code to "declare" again (even if it's generated) it didn't make sense to me.

Thanks everyone ... I'll just add the declaration code, and I'll be set.
 
Upvote 0
Top