title: How to set the image from drawable dynamically in android?
body: <p>I am storing my project related images in drawable folder. Also I am storing the image names in string variable and dynamically I am trying to set those images to the imageview. But the image is not displaying. Please help me in this regard. </p>
  
  <p>My Code:  </p>
  
  <pre><code>int res = getResources().getIdentifier(imagename, "drawable", this.getPackageName());
  imageview= (ImageView)findViewById(R.id.imageView);
  imageview.setImageResource(res);
  </code></pre>
  
  <p>In the above code "imagename" is the string variable which contains the image name.</p>
  
  <p>Thanks in advance</p>