title: Android Multi-dimensional arrays in arrays.xml
body: <p>In an arrays.xml file, in the res folder, are defined several arrays:</p>
  
  <pre><code>       &lt;string-array name="all"&gt;
         &lt;item&gt; a1 &lt;/item&gt;
         &lt;item&gt; a2 &lt;/item&gt;
         &lt;/string-array&gt;
  
         &lt;string-array name="a1"&gt;
         &lt;item&gt; x &lt;/item&gt;
         &lt;item&gt; y &lt;/item&gt;
         &lt;/string-array&gt;
  
          &lt;string-array name="a2"&gt;
         &lt;item&gt; z &lt;/item&gt;
         &lt;item&gt; t &lt;/item&gt;
         &lt;/string-array&gt;
  </code></pre>
  
  <p>I would like to read the "all" array and sequence into the a1 or a2 arrays dependent on a selection in "all", without having to build a switch/case statement (the real arrays are more complex). The code would look like this, but Java/Android complains about the second line. It wants R.array to be a constant like
  R.array.a1 or R.array.a2 and not with a variable. </p>
  
  <p>Is it possible to do the following (line 2), </p>
  
  <pre><code>            String[] temp_items = getResources().getStringArray(R.array.all1); 
              String[] items = getResources().getStringArray(R.array.temp_items[0]);    
  </code></pre>
  
  <p>I can also solve this by putting the arrays in a utility class in java and bypassing the arrays.xml file. </p>
  
  <p>Is this possible?
             
              a1 
              a2 
             </p>
  
  <pre><code>       &lt;string-array name="a1"&gt;
         &lt;item&gt; x &lt;/item&gt;
         &lt;item&gt; y &lt;/item&gt;
         &lt;/string-array&gt;
  
          &lt;string-array name="a2"&gt;
         &lt;item&gt; z &lt;/item&gt;
         &lt;item&gt; t &lt;/item&gt;
         &lt;/string-array&gt;
  </code></pre>