title: Cannot I do a getResources.getString dynamically?
body: <p>I'm trying to fill a <code>Spinner</code> with the values of some <code>Strings</code> of <code>string.xml</code>. I'm trying to do like that:</p>
  
  <pre><code>   final List&lt;String&gt; list = new ArrayList&lt;String&gt;();
     for (int i = 0; i &lt; 86; i++) {
        String resource = "R.string." + ntpServers[i][0];
        list.add(getResources().getString(resource));
     }
  </code></pre>
  
  <p>I have strings like the next ones.</p>
  
  <pre><code>&lt;string name="AT"&gt;Austria&lt;/string&gt;
  &lt;string name="BY"&gt;Belarus&lt;/string&gt;
  &lt;string name="BE"&gt;Belgium&lt;/string&gt;
  </code></pre>
  
  <p>And <strong>from a Geocoder</strong> I get a country code like AT, BY, etc. Which are stored in the ntpServers array. I want to fill the spinner with the name saved in the correspondent string, but I cannot do <code>getResources().getString(resource)</code> because <code>resource</code> is a <code>String</code> not an <code>int</code>.</p>
  
  <p>How can I solve this?</p>
  
  <p>Thanks for your advices.</p>
  
  <p>P.D.:</p>
  
  <p>I get the next sequence:</p>
  
  <p>For Example:</p>
  
  <pre><code>geocoder.getCountry() = ES --&gt; ntpServers[36][0] = ES --&gt; R.string.ES = """Spain""" 
  </code></pre>
  
  <p>Which is the string that I want in the spinner.</p>
  
  <p><strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em></strong></p>
  
  <p>This is what I'm trying to do now. I'm using <strong>getIdentifier</strong>.</p>
  
  <pre><code>final List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  for (int i = 0; i &lt; 86; i++) {
     String resource = "R.string." + ntpServers[i][0];
     Log.i("RESOURCE", resource);
     Log.i("getResource", "" + getResources().getIdentifier(resource, "string", getPackageName()));
                  list.add(getResources().getString(getResources().getIdentifier(resource, "string", getPackageName())));
  }
  </code></pre>
  
  <p>And this is the log cat</p>
  
  <pre><code>09-18 19:32:43.815: I/RESOURCE(31268): R.string.Global
  09-18 19:32:43.815: I/getResource(31268): 0
  09-18 19:32:43.815: W/ResourceType(31268): No package identifier when getting value for resource number 0x00000000
  09-18 19:32:43.815: D/AndroidRuntime(31268): Shutting down VM
  09-18 19:32:43.815: W/dalvikvm(31268): threadid=1: thread exiting with uncaught exception (group=0x40fa92a0)
  09-18 19:32:43.815: E/AndroidRuntime(31268): FATAL EXCEPTION: main
  09-18 19:32:43.815: E/AndroidRuntime(31268): android.content.res.Resources$NotFoundException: String resource ID #0x0
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.content.res.Resources.getText(Resources.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.content.res.Resources.getString(Resources.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at victor.martin.gplace.MainActivity$3.run(MainActivity.java:790)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.os.Handler.handleCallback(Handler.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.os.Handler.dispatchMessage(Handler.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.os.Looper.loop(Looper.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at android.app.ActivityThread.main(ActivityThread.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at java.lang.reflect.Method.invokeNative(Native Method)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at java.lang.reflect.Method.invoke(Method.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
  09-18 19:32:43.815: E/AndroidRuntime(31268):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>And this is the R.java:</p>
  
  <pre><code>public static final class string {
          public static final int AE=0x7f080049;
          public static final int AO=0x7f08005b;
          ...
          public static final int Global=0x7f080008;
  </code></pre>
  
  <p>Let's see if you can guide me more.</p>
  
  <p>Eternal Thanks ^^</p>