title: Android - Set different ImageView to each item in a list
body: <p>I am trying to set a different ImageView to each row of my list. All of the Images are stored in my assets folder so I stored the path from the assets folder in an xml file. In my code below I am setting the title and description of each row in the list but I dont know how to set a specific imageView.</p>
  
  <p>Below is my code</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      // TODO Auto-generated method stub
  
  
      Bundle getbundle = getArguments();
      KEY_CATEGORY= getbundle.getString("id");
  
      View v = inflater.inflate(R.layout.main, container, false);
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; menuItems = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      XMLParser parser = new XMLParser();
      String xml = getXml("Images.xml"); // getting XML
      Document doc = parser.getDomElement(xml); // getting DOM element
  
      NodeList nl = doc.getElementsByTagName(KEY_CATEGORY);
      // looping through all item nodes &lt;item&gt;
      for (int i = 0; i &lt; nl.getLength(); i++) {
          // creating new HashMap
          HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
          Element e = (Element) nl.item(i);
          // adding each child node to HashMap key =&gt; value
          map.put(KEY_ID, parser.getValue(e, KEY_ID));
          map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
          map.put(KEY_MUSCLE, "Rs." + parser.getValue(e, KEY_MUSCLE));
          map.put(KEY_DESC, parser.getValue(e, KEY_DESC));
          map.put(KEY_FILE, parser.getValue(e, KEY_FILE));
          // adding HashList to ArrayList
          menuItems.add(map);
      }
  
      // Adding menuItems to ListView
      ListAdapter adapter = new SimpleAdapter(getActivity(), menuItems,
              R.layout.list_item,
              new String[] { KEY_NAME, KEY_DESC, KEY_MUSCLE, KEY_FILE }, new int[] {
                      R.id.name, R.id.desciption, R.id.cost, R.id.tvfilepath });
  
      setListAdapter(adapter);
  
      ListView lv = (ListView)v.findViewById(android.R.id.list);
      return v;
  }
  </code></pre>
  
  <p>and here is the xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"&gt;  
  &lt;ImageView
              android:id="@+id/imageView1"
              android:layout_width="80dp"
              android:layout_height="80dp" /&gt;
  &lt;LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
      &lt;!-- Name Label --&gt;
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textColor="#dc6800"
          android:textSize="16sp"
          android:textStyle="bold"
          android:paddingTop="6dip"
          android:paddingBottom="2dip" /&gt;
      &lt;!-- Description label --&gt;
      &lt;TextView
          android:id="@+id/desciption"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textColor="#acacac"
          android:paddingBottom="2dip"&gt;
      &lt;/TextView&gt;
      &lt;!-- Linear layout for cost and price Cost: Rs.100 --&gt;
      &lt;LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"&gt;
      &lt;!-- Cost Label --&gt;
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textColor="#5d5d5d"
          android:gravity="left"
          android:textStyle="bold"
          android:text="Cost: " &gt;
      &lt;/TextView&gt;
      &lt;!-- Price Label --&gt;
      &lt;TextView
          android:id="@+id/cost"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textColor="#acacac" 
          android:textStyle="bold"
          android:gravity="left"&gt;
      &lt;/TextView&gt;
  
      &lt;TextView
          android:id="@+id/tvfilepath"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textColor="#acacac" 
          android:textStyle="bold"/&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>