title: How to load a resource name procedurally?
body: <p>A little context, I'm using Eclipse to write an android game/app using Java. One function returns a variable "flag" which tells a render function to draw a window on top of the screen. My code looks like this:</p>
  
  <pre><code>if(flag == 3000){
  window.setBitmap(BitmapFactory.decodeResource(res, R.drawable.tutorialdiagram_3000));}
  
  else if(flag == 3001){
  window.setBitmap(BitmapFactory.decodeResource(res,R.drawable.tutorialdiagram_3001));}
  
  else if(flag == 3002){
  window.setBitmap(BitmapFactory.decodeResource(res,R.drawable.tutorialdiagram_3002));}
  
  else if(flag == 3003){
  window.setBitmap(BitmapFactory.decodeResource(res,R.drawable.tutorialdiagram_3003));}
  
  else if(flag == 3004){
  window.setBitmap(BitmapFactory.decodeResource(res,R.drawable.tutorialdiagram_3004));}
  </code></pre>
  
  <p>It would be nice if I could simply do all of this with one line. It would be something like (from Flash actionscript)</p>
  
  <pre><code>if(flag &gt;= 3000){
      window.setBitmap(BitmapFactory.decodeResource(res, escape("R.drawable.tutorialdiagram_" + flag)));
  }
  </code></pre>
  
  <p>I'm sure there is a super easy way to do this. I should have learned it on day 1, etc. Who can be the first to school me?</p>