108 CHAPTER 4: Introduction to XML: Defining an Android App, Its Design, and Constants
The three
action_settings, and hello_world, and define the text strings for the application icon and title bar,
currently HelloUniverse, as well as a menu item labeled Settings and the “Hello world!” message
that your app writes to the display screen.
The way a
part of the string value XML definition to define the string variable name, and the actual text value for
a string goes inside of the
XML definition would thus be:
Next, we will edit our application name, by editing this XML
strings.xml file, so that there is a space between the Hello and Universe. Your AndroidManifest.xml
file uses this app_name constant (as you will see in a later section of this chapter) to determine what
the application icon name (under the icon graphic) and the title of the app in the title bar will be.
Making this simple edit will make your app look more professional, and will be easier to read for your
end users. Let’s do this next, and then we can get into more complicated XML definitions after that.
XML Constants: Editing Constants Using XML
Click your text insertion cursor between the Hello and Universe in the first
and hit the spacebar to add a space character, as is shown in Figure 4-3. This simple edit will
change all of the instances of HelloUniverse in your application to be Hello Universe. After we look
at the dimensions, styles, and OS themes defined by XML, we will run the Android application in
the Nexus One Android Virtual Device (AVD) emulator and you can see this for yourself. For now,
however, you will just have to trust me and the app modifications we are making.
Figure 4-2. The strings.xml file located in the /res/values folder and with three