title: Android - retrieve string array from resources
body: <p>Below is the code that i made to retrieve the string array item:</p>
  
  <pre><code>String[] menuArray;
  
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {       
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ScrollView sv = new ScrollView(this);
      LinearLayout ll = new LinearLayout(this);
      ll.setOrientation(LinearLayout.VERTICAL);
      sv.addView(ll);
  
   // Create an ArrayAdapter that will contain all list items
      ArrayAdapter&lt;String&gt; adapter;
  
      menuArray = getResources().getStringArray(R.array.menu); 
  
  
      for(int i = 0; i &lt; menuArray.length; i++) 
      {
          Button b = new Button(this);
          b.setText(menuArray[i]);
          ll.addView(b);
      }
  
      this.setContentView(sv);
   }
  </code></pre>
  
  <p>This is the strings.xml file:</p>
  
  <pre><code> &lt;string-array name="menu"&gt;
          &lt;item&gt;1&lt;/item&gt;
          &lt;item&gt;2&lt;/item&gt;
          &lt;item&gt;3&lt;/item&gt;
          &lt;/string-array&gt;
  </code></pre>
  
  <p>However, the <strong><em>R.array.menu</em></strong> having this issue to compile:
  As of ADT 14, resource fields cannot be used as switch cases. 
  Invoke this fix to get more information.</p>