App Basics

Your GeoQuiz application will consist of an activity and a layout:

  • An activity is an instance of Activity, a class in the Android SDK. An activity is responsible for managing user interaction with a screen of information.

    You write subclasses of Activity to implement the functionality that your app requires. A simple application may need only one subclass; a complex application can have many.

    GeoQuiz is a simple app and will start off with a single Activity subclass named MainActivity. MainActivity will manage the user interface, or UI, shown in Figure 1.1.

  • A layout defines a set of UI objects and the objects’ positions on the screen. A layout is made up of definitions written in XML. Each definition is used to create an object that appears onscreen, like a button or some text.

    GeoQuiz will include a layout file named activity_main.xml. The XML in this file will define the UI shown in Figure 1.1.

The relationship between MainActivity and activity_main.xml is diagrammed in Figure 1.2.

Figure 1.2  MainActivity manages what activity_main.xml defines

MainActivity manages what activity_main.xml defines

With those ideas in mind, let’s build an app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.174.174