title: How to inflate new copies of an ImageView object on a layout?
body: <p>What I am trying to do is create <em>N</em> (in this case 9) copies of the ImageView object <code>R.id.tile</code>, place each of them at different coordinates on the layout, and give each its own unique identifier.</p>
  
  <p><strong>board_layout.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/backgroundcolor"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:id="@+id/topbar"
          ... &gt;
  
          &lt;ImageButton
              android:id="@+id/imagebutton"
              ... /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;RelativeLayout
          android:id="@+id/board"
          android:layout_width="match_parent"
          android:layout_height="345dp"
          android:layout_centerVertical="true"
          android:background="@drawable/wwfboard" &gt;
  
          &lt;view class="languid.legend.xsolver.DrawView"
              android:id="@+id/myView"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" /&gt;
  
          &lt;ImageView
              android:id="@+id/tile"
              android:layout_width="21dp"
              android:layout_height="21dp"
              android:src="@drawable/tile" /&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><br/>
  <strong>BoardLayout.class:</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstance)
  {   super.onCreate(savedInstance);
      setContentView(R.layout.board_layout);
      LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View[] tiles = new ImageView[9];
      entire_layout = (RelativeLayout)findViewById(R.layout.board_layout);
  
  
      for(int i = 0; i&lt;tiles.length; i++){
          tiles[i] = (ImageView) inflater.inflate(R.layout.board_layout, null);
          tiles[i].setId(1000+i);
          params = new RelativeLayout.LayoutParams(-1, 345);
          params.leftMargin = 32*2*i;
          params.topMargin = 34*2*i;
          entire_layout.addView(tiles[i]);
      }
      ...
  </code></pre>
  
  <p>However, I keep getting <strong>"Source not found"</strong> errors on the last line: <code>layout.addView(tiles[i]);</code>.. <br/> <br/>
  Any ideas why? <br/><br/>
  (Side question: is RelativeLayout better than AbsoluteLayout if you're working with coordinates?)</p>