title: How to set ImageViews source dynamically from ArrayList<String> with Drawable image name?
body: <p>I have a ListView with an ImageView, a TextView and another ImageView in each row.</p>
  
  <p>The code below is the xml of my ListView row:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="60dp"
  android:background="#FFF"&gt;
  &lt;ImageView
  android:id="@+id/left"
  android:layout_width="50dp"
  android:layout_height="50dp"
  android:layout_gravity="center"
  android:src="@drawable/ic_default"
  android:layout_marginLeft="10dp"
  android:layout_marginRight="10dp" /&gt;
  &lt;TextView
  android:id="@+id/text"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:gravity="center"
  android:layout_weight="1"
  android:textSize="16sp" /&gt;
  &lt;ImageView
  android:id="@+id/right"
  android:layout_width="50dp"
  android:layout_height="match_parent"
  android:layout_gravity="center"
  android:src="@drawable/ic_cena_play"
  android:layout_marginRight="0dp"
  android:layout_marginLeft="10dp"
  android:clickable="true"
  android:background="@drawable/mybuttonplay" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I have an ArrayList &lt; String > with the names of Drawables I want to put in the first ImageView of the rows. I want to change the ImageViews source "ic_default" to the ones which have the name in ArrayList, dinamically.</p>
  
  <p>In my Activity, inside onCreate(), I am using an Adapter, as the code below:</p>
  
  <pre><code>ArrayList&lt;String&gt; items = new ArrayList();
  items.add("Star");
  items.add("Moon");
  items.add("Dog");
  items.add("Bird");
  items.add("Tree");
  ArrayList&lt;String&gt; itemsimg = new ArrayList();
  itemsimg.add("ic_star");
  itemsimg.add("ic_moon");
  itemsimg.add("ic_dog");
  itemsimg.add("ic_bird");
  itemsimg.add("ic_tree");
  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.scenesrow, R.id.text, items) {
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              View row =  super.getView(position, convertView, parent);
              ImageView left = (ImageView) row.findViewById(R.id.left);
              //here I want to change the resource
              //Like if I had a function called getRosourceId(). DOES IT EXIST?!
              int x = getResourceId( itemsimg.get(position) );
              left.setImageResource(x);
              View right = row.findViewById(R.id.right);
              right.setTag(position);
              right.setOnClickListener(ScenesActivity.this);
              return row;
          }
      };
  </code></pre>
  
  <p><strong>Updated</strong></p>
  
  <p>Thanks for answers! Now I can change the ImageView source dinamically <strong>(but not yet from the ArrayList &lt; String >)</strong>. The setImageResource() method was not available before because I had a View. With the cast to ImageView you all suggested, big part of the problem was okay. But the answers do not cover the dinamically thing of the "name of the resource".</p>
  
  <p>The last problem now is the left.setImageResource(resId); method asks for an ID from Resource, and I have a String. How to do it?</p>
  
  <p>And sorry, other code version had some mistakes. Now it is fixed. I think the last problem is clear now.</p>