title: Android: Accessing string.xml using variable name
body: <p>I want to display a message to the user depending upon a prompt I receive from another part of the program. There can be a number of prompts &amp; they are stored in an enum.</p>
  
  <p>These are my prompts:</p>
  
  <p><strong>Defs.java</strong></p>
  
  <pre><code>public enum Prompt
  {
      PromptA,
      PromptB,
      PromptC,
  }
  </code></pre>
  
  <p>I have the externalized strings stored in resources on these lines:</p>
  
  <p><strong>res/values/strings.xml</strong></p>
  
  <pre><code>&lt;string name="PromptA"&gt;Error in execution&lt;/string&gt;
  &lt;string name="PromptB"&gt;Process completed successfully&lt;/string&gt;
  &lt;string name="PromptC"&gt;Please try again&lt;/string&gt;
  </code></pre>
  
  <p>Now in my <strong>main Activity</strong> screen a method is called by some other part:</p>
  
  <pre><code>public void showPrompt(Prompt prompt) {
      String message = getString(R.string.&lt;**what-do-I-put-here?**&gt;);
      //show a dialog box with message
  }
  </code></pre>
  
  <p>I know this can be done with a huge if-else block (there are tons of prompts in the actual application) or a switch statement. 
  It will be really ugly. </p>
  
  <p>Is there a better way to do this?</p>