From android help:
Activity is a single focused thing that a user can do. Almost all actions interact with the user, so the Activity class takes care of creating a window for you in which you can place your user interface using setContentView (View).
This process of creating a window is an expensive operation, and you only need to call setContentView-once in the Activity .
- If you need to add xml resources, you can use the layout of the inflatable system . (tip: always transfer container link to inflate)
- If you think you need to use more than one layout file (a whole new ui), you should consider creating a new Activity .
About your questions:
So my question is why this layout is being created; Is this generated for convenience or is it a good practice to always have a specific layout related to an Activity?
Convenience, you use the wizard to create an Activity. In most cases, you implement an XML resource for your activity, so the wizard creates it for you.
Also, should an Activity always have a layout, or do I have an activity that never uses a layout?
It is not required to have a layout for the Activity, but a window will be created. An example of this is a splash screen in which you display an image but do not set the presentation of the content.
source share