Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Read array from xml file in android
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <resources>
  4.     <string-array
  5.         name="difficulty_level_names">
  6.         <item>
  7.             <name>IELTS</name>
  8.             <type>1</type>
  9.         </item>
  10.  
  11.         <item>
  12.             <name>SAT</name>
  13.             <type>2</type>
  14.         </item>
  15.  
  16.         ................
  17.         .........
  18.  
  19.     </string-array>
  20. </resources>
  21.        
  22. final int PROPERTIES_COUNT_IN_OBJECT = 2;
  23. int objectIndex   = 0; // the first element in your's example
  24. int propertyIndex = 1; // the second property: <type>1</type>
  25. int indexInArray  = objectIndex * PROPERTIES_COUNT_IN_OBJECT + propertyIndex;