The easiest way of defining your user interface (and the views, ViewGroups, and layout elements that it contains) is via your project's XML file.
Android provides a straightforward XML vocabulary that gives your user interface a human-readable structure, and creates a separation between the code that defines your UI and the code that controls your app's behavior. You define your layouts in XML in a dedicated layout resource file. This helps to keep both sets of code cleaner, and it gives you the ability to tweak and refine your UI without having to touch your app's underlying code. For example, you can update your layout to support an additional language without having to touch the previously-tested code.
Declaring your UI in XML also makes it easier to provide alternate layouts; for example, at some point, you may want to create an alternative version of your layout that's optimized for landscape mode. If you declare your original...