Difference between activity and content

6

I do not know if this is the right place for this, if not for guidance where I throw this doubt. I'm learning how to develop apps in Android Studio, and I'm following some tutorials. Some cases have noticed that some have only activity and others besides activity also has content which is the case of this:

andthisisjusttheactivity

Whenever I create a project it never generates the context. I would like to know the difference between them and their purpose. and if you need to have the context.

    
asked by anonymous 21.12.2017 / 15:31

2 answers

2

When you create a Basic Activity it creates the xml of activity and content together, this template already comes with FABButton along with the layout so it creates 2 files ideally to use content to put other components so the operation of FABButton is not affected.

If you do not want to create this template, always select Empty Activity when creating a new one.

I hope that helps you.

    
21.12.2017 / 16:27
2

What you are referring to are just layout file names .

A layout can be used by an Activity or not. Among others, they are used in Activities, Fragments, ListView's or RecyclerView's items.

A layout file can also use other files as an integral part of it, ie parts of a layout can be in other layout in>.

This is the case (I think) of the first example that says: the file content_primeira.xml is used in the file activity_primeira.xml .

Adding layout files to one another is done by using tag <include> .

If you see the xml of activity_primeira.xml you will find a line with the following content

<include layout="@layout/content_primeira"/>

One advantage of this approach is the possibility of an layout / layout being used in more than one layout.     

21.12.2017 / 16:52