Android Question New user - relationship between Activity Module and Layouts

Ryan S.

New Member
Licensed User
I am working through some samples and tutorials, and I can't figure out the relationship between an Activity Module and a Layout. If I create a layout, add some controls, and then generate the events and code, it seems to all go into Main Activity Module. If I create a second layout and generate code, it still all goes into Main Activity Module.
Are the layouts and modules connected in some way that I am not seeing?

Ryan
 

LucaMs

Expert
Licensed User
Longtime User
No, layouts and activities are not strictly related; you can load a layout even into a Panel (by code, not by Designer).

The fact is that if you generate members from within the Designer, the code will be written to the current module, even if it was not an Activity (code module, service module or class module).

So you have to pay attention to which module (Activity, in this case) is currently open.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
the code will be written to the current module, even if it was not an Activity (code module, service module or class module).
Not exactly, if the current active module is a code module and you try to generate a Dim declaration or an event routine you get a message that this current module doesn't allow user interfaces.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Not exactly, if the current active module is a code module and you try to generate a Dim declaration or an event routine you get a message that this current module doesn't allow user interfaces.
I hadn't noticed (it had never happened to me, I was always lucky to have the right activity open :D); maybe not from the first versions of B4A.

I see that it is the same also for the service modules.
 
Upvote 0
Top