Android Tutorial

(avery) #1
Android Tutorial 153

create individual string resources for each soup name and then
store the references to those string resources in the string-array
(instead of the text).

To do this,we define the string resources in the /res/strings.xml file
like this:

<?xml version=”1.0” encoding=”utf-8”?>



Application Name
Organic Chicken Noodle
Veggie Minestrone
New England LobsterChowder

And then we can define a localizable string-array that references
the string resources by name in the /res/arrays.xml file like this:

<?xml version=”1.0” encoding=”utf-8”?>




@string/minestrone_soup
@string/chowder_soup
@string/chicken_soup


You can also use references to make aliases to other resources. For
example, you can alias the system resource for the OK string to an
application resource name by including the following in your
strings.xml resource file:

<?xml version=”1.0” encoding=”utf-8”?>



@android:string/ok
Free download pdf