
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.64 KB | hits: 20 | expires: Never
Read array from xml file in android
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array
name="difficulty_level_names">
<item>
<name>IELTS</name>
<type>1</type>
</item>
<item>
<name>SAT</name>
<type>2</type>
</item>
................
.........
</string-array>
</resources>
final int PROPERTIES_COUNT_IN_OBJECT = 2;
int objectIndex = 0; // the first element in your's example
int propertyIndex = 1; // the second property: <type>1</type>
int indexInArray = objectIndex * PROPERTIES_COUNT_IN_OBJECT + propertyIndex;