Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Chapter 18  Localization


Run CriminalIntent on a device with the language set to English. The app displays the resource ID for
crime_title_label instead of the TITLE text ( Figure 18.5).


Figure 18.5  Referencing missing English version of title string from XML


Even worse, if an unmatched string resource is referenced in your Java code, the app will crash. To see
this in action, comment out crime_report_subject in the English values/strings.xml.


Listing 18.3  Commenting out English crime_report_subject
(res/values/strings.xml)


there is no suspect.
the suspect is %s.

(Recall that crime_report_subject is referenced by the crime report button’s click listener in
CrimeFragment.java:)

Free download pdf