title: Dynamically show images from resource/drawable
body: <p>I'm trying to put different images (.jpg , .png) dynamically into a <code>ListView</code>  from r<code>es/drawable</code> .
  The names from the images I get from a database.
  The images themselves are in the <code>res/drawable</code> folder.</p>
  
  <p>This is what I already have, With an error of :D</p>
  
  <p>String imgName;  --> There are the img names I need from the database</p>
  
  <pre><code>Drawable drawable;    
      drawable = Class.appContext.getResources().getDrawable(Class.appContext.getResources().getIdentifier("com.example.test:drawable/"+imgName,null,null));  
  </code></pre>
  
  <p>Then I get this into a <code>ArrayList</code> for every image in the database(+- 200 images):</p>
  
  <pre><code>ArrayList&lt;HashMap&lt;String, Object&gt;&gt; list = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
  HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
  
  map = new HashMap&lt;String, Object&gt;();
  map.put("img",drawable);
  
            map.put("text", "some text");
            list.add(map);
  </code></pre>
  
  <p>Now I RETURN list;</p>
  
  <p>In the Class where I call :</p>
  
  <pre><code>listReceive = Class.getImages(appContext); 
  
  listSetup = new SimpleAdapter(this, listReceive, R.layout.row,
                          new String[] {"img", "text"}, new int[] {R.id.IMG_CELL, R.id.TEXT_CELL});
                  lvList.setAdapter(listSetup);
  </code></pre>
  
  <p>XML row is an <code>ImageView</code> and a <code>TextView</code>.</p>
  
  <blockquote>
    <p>System.out :resolveUri failed on bad
    bitmap uri:
    android.drawable.bitmapDrawable@405739
    resolveUri failed on bad bitmap uri:
    android.drawable.bitmapDrawable@405639
    resolveUri failed on bad bitmap uri:
    android.drawable.bitmapDrawable@405959
    resolveUri failed on bad bitmap uri:
    android.drawable.bitmapDrawable@405677...
    ... ...</p>
  </blockquote>
  
  <p>I got it working when I saved images into local or SDcard memory, and then put the path inside the arraylist like: </p>
  
  <pre><code>map.put("img","/data/data/com.example.test/images/" + imgName);
  </code></pre>
  
  <p>I can't use this because then i will need to copy the pictures from <code>res/drawable</code> onto local or SD.This takes up 2 times the memory. can't have that of.</p>
  
  <p>There must be a way to get images dynamically from the drawable.</p>
  
  <p>Any one knows what I'm missing here?
  Thanks.</p>