title: Android Spawn Multiple ImageView with Different Position
body: <p>I'm creating an android application and I want to spawn multiple imageviews with same image and different position.I have a class for the image and with for loop I created 15 images and add it to ArrayList and set differen position with enhanced for loop ,but now they are 15 images with only one position and it seems like 1 image.Look at my code</p>
  
  <p>This is the main class
  </p>
  
  <pre><code>private ImageView pumpkinImg;
  private int imageY = 50;
  private int imageX = 50;
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_play_second);
  
      pumpkinImg = (ImageView) findViewById(R.id.pumpkin_second);
  
      ArrayList&lt;Pumpkin&gt; pumpkins = new ArrayList&lt;Pumpkin&gt;();
      for(int i = 0; i &lt; 15; i ++){
          Pumpkin p = new Pumpkin(pumpkinImg);
  
          pumpkins.add(p);
      }
      for(Pumpkin pmk : pumpkins){
  
          pmk.setV(pumpkinImg);
          pmk.setPosX(pmk.getV(), imageX);
          pmk.setPosY(pmk.getV(), imageY);
  
          imageX += 20;
          imageY += 20;
      }
  
  
  }
  </code></pre>
  
  <p>And here is my pumpkin class</p>
  
  
  
  <pre><code>public class Pumpkin {
  
  private int x;
  private int y;
  ImageView v;
  
  public Pumpkin(ImageView v){
  
  
  }
  
  public void setPosX(ImageView v,int posX){
      v.setX(posX);
  }
  public void setPosY(ImageView v,int posY){
      v.setY(posY);
  }
  
  public ImageView getV() {
      return v;
  }
  
  public void setV(ImageView v) {
      this.v = v;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my XML FILE : </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="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="150dp"
      android:text="@string/level_two_welcome"
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;ImageView
      android:id="@+id/pumpkin_second"
      android:layout_width="50dp"
      android:layout_height="50dp"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:src="@drawable/level_2" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>