Книга: Beginning Android



Array resources are designed to hold lists of simple strings, such as a list of honorifics (Mr., Mrs., Ms., Dr., etc.).

In the resource file, you need one string-array element per array, with a name attribute for the unique name you are giving the array. Then, add one or more child item elements, each of which have a single text element with the value for that entry in the array:

<?xml version="1.0" encoding="utf-8"?>
 <string-array name="cities">
 <string-array name="airport_codes">

From your Java code, you can then use Resources.getStringArray() to get a String[] of the items in the list. The parameter to getStringArray() is your unique name for the array, prefixed with R.array. (e.g., Resources.getStringArray(R.array.honorifics)).

Оглавление книги

Оглавление статьи/книги

Генерация: 0.141. Запросов К БД/Cache: 2 / 0
Вверх Вниз