O'Reilly logo

Hello, Android, 4th Edition by Ed Burnette

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining Resources

Almost all resources are defined with XML (see Using Resources). Thankfully, the XML is precompiled at build time so you don’t have to pay a performance penalty for parsing it when the program runs.

Strings

Instead of hard-coding text strings in our program code and layouts, we store them all in one place: the strings.xml resource file in the res/values folder. That will make it much easier to translate the strings when it comes time to internationalize your app for foreign markets. Here are the definitions for all the strings we’ve used so far in the Tic-Tac-Toe program:

ticTacToev1/src/main/res/values/strings.xml
 
<?xml version="1.0" encoding="utf-8"?>
 
<resources>
 
<string​ name=​"app_name"​​>​UT3​</string>
 
<string ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required