Question : What is a correct statement about an XML layout file?
1. A layout PNG image file
2. A file used to draw the content of an Activity
3. A file that contains all application permission information
4. A file that contains a single activity widget
Correct Answer : 2 Explanation: A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. You can declare a layout in two ways:
Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically. The Android framework gives you the flexibility to use either or both of these methods for declaring and managing your application's UI. For example, you could declare your application's default layouts in XML, including the screen elements that will appear in them and their properties. You could then add code in your application that would modify the state of the screen objects, including those declared in XML, at run time.
You should also try the Hierarchy Viewer tool, for debugging layouts - it reveals layout property values, draws wireframes with padding/margin indicators, and full rendered views while you debug on the emulator or device. The layoutopt tool lets you quickly analyze your layouts and hierarchies for inefficiencies or other problems. The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems. As such, this document focuses on teaching you how to declare your layout in XML. If you're interested in instantiating View objects at runtime, refer to the ViewGroup and View class references.
In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given XML element. However, note that not all vocabulary is identical. In some cases, there are slight naming differences. For example, the EditText element has a text attribute that corresponds to EditText.setText().
Question : What does the src folder contain?
1. Image and icon files
2. XML resource files
3. The application manifest file
4. Java source code files
Correct Answer : 4 Explanation:
Question : Which file specifies the minimum required Android SDK version your application supports?
1. main.xml
2. R.java
3. strings.xml
4. AndroidManifest.xml
Correct Answer : 4 Explanation: Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code. Among other things, the manifest does the following:
It names the Java package for the application. The package name serves as a unique identifier for the application. It describes the components of the application - the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched. It determines which processes will host application components. It declares which permissions the application must have in order to access protected parts of the API and interact with other applications. It also declares the permissions that others are required to have in order to interact with the application's components. It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published. It declares the minimum level of the Android API that the application requires. It lists the libraries that the application must be linked against.