There's a very simple use of arrays in Android that gets in an XML file.
Creating an array Resource
Create a Arrays.xml file under the value directory
Then use the <string-array> or <integer-array> tags in the arrays.xml file to define the array:
<?xml version= "1.0" encoding= "Utf-8"?><resources> <string-array name= "Languages" > < Item>c language </item> <item>java </item> <item>C#</item> <item>php </item> <item>HTML</item> </string-array> <integer-array name= "Reminder_ Methods_values "translatable=" false "> <item>1</item> <item>2</item> <item>3</item> </integer-array> </resources>
Referencing array resources: Referencing in Java code
Resources res == = Res.getintarray (r.array.reminder_methods_values);
Referencing in XML
Take the spinner control as an example, because the entries property of spinner just needs to be an array resource
<Spinner android:id= "@+id/spinner1" android:layout_width= "Match_parent" Android:layout_height= "Wrap_content" android:entries= "@array/languages" />
Note that the reference above is @array.
In fact, the array resources are not necessarily defined in the Values/arrays.xml file, this is an unwritten convention, the above <string-array name= "languages" > The definition is also possible in Strings.xml.
Android system for all XML resource files is actually no different, think that the values of the resource type is not put in what file, but in the name of the tag, such as the String-array tag name determines that this is an array resource.
It is recommended that array resources be uniformly placed in values/arrays.xml.
Android uses an array resource in an XML file