You are able to define many different grammatical forms for a particular word

You are able to define many different grammatical

This preview shows page 41 - 49 out of 112 pages.

You are able to define many different grammatical forms for a particular word. To define more than one quantity form of a given word in your string resource file, you simply specify more than one <item> element and provide a value for the quantity attribute for that particular <item> denoting the word’s quantity.
Image of page 41

Subscribe to view the full document.

Working with Quantity Strings (Cont’d) Value Description zero Used for languages that have words with a zero quantity form. one Used for languages that have words with a singular quantity form. two Used for languages that have words for specifying two. few Used for languages that have words for specifying a small quantity batch. many Used for languages that have words for specifying a large quantity batch. other Used for languages that have words that do not have a quantity form.
Image of page 42
Working with String Arrays You can specify lists of strings in resource files. This is a good way to store menu options and drop-down list values. String arrays are defined in XML under the res/values/ project directory. They are compiled into the application package at build time. String arrays are appropriately tagged with the <string- array> tag. They usually include a number of <item> child tags, one for each string in the array.
Image of page 43

Subscribe to view the full document.

Working with String Arrays (Cont’d) <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="flavors"> <item>Vanilla</item> <item>Chocolate</item> <item>Strawberry</item> <item>Coffee</item> <item>Sherbet</item> </string-array> <string-array name="soups"> <item>Vegetable minestrone</item> <item>New England clam chowder</item> <item>Organic chicken noodle</item> </string-array> </resources>
Image of page 44
Working with String Arrays (Cont’d) Accessing string array resources is easy. The method getStringArray() retrieves a string array from a resource file, in this case one named flavors : String[] aFlavors = getResources().getStringArray(R.array.flavors);
Image of page 45

Subscribe to view the full document.