Android Question New user - relationship between Activity Module and Layouts

Discussion in 'Android Questions' started by Ryan S., Jun 22, 2019.

  1. Ryan S.

    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
     
  2. LucaMs

    LucaMs Expert Licensed 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.
     
  3. Ryan S.

    Ryan S. New Member Licensed User

    Ok, that makes sense. Thank you very much!
     
  4. klaus

    klaus Expert Licensed 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.
     
    LucaMs likes this.
  5. José J. Aguilar

    José J. Aguilar Active Member Licensed User

    Frank.G likes this.
  6. LucaMs

    LucaMs Expert Licensed User

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice