title: Image(s) placement over a image in Android Saving memory
body: <p>I'm placing ImageView's in a RelativeLayout.  I'm setting them with LayoutParams and using setMargins() to set the location of each picture.  The max number of Images that will be placed on top of the first one will only reach 8. Their are 5 diffident Images and 8 positions on the screen where they can be placed.  I would like to create the Images as their corresponding buttons are pressed and to be able to set that Image into the RelativeLayout and display the change.  I would like a way to clear all the Images off the screen except for the main/ background ImageView.  I don't like to populate 8 X 5 = 40 Images and then hide them all then change their view to Visible when i need them to show. I need something that will populate as need be but able to destory or remove when I clear it out.</p>
  
  <p>Thanks,
  Zelda</p>
  
  <pre><code>aButton.setOnClickListener(new OnClickListener(){
          public void onClick(View v)
          {
              noteNumber++;
              if(noteNumber &lt;= 8){
                  note n = new note(getBaseContext());
                  n.setNoteNumber(noteNumber);
                  n.setHeight(85);
                  images.add(n);  //ArrayList()
              }
              populate();
          }
      });
  }
  public void populate(){
      //if(noteNumber &lt; 9){
      for(note a : images){   
          //note a = images.get(noteNumber-1); //images is of type ArrayList&lt;ImageView&gt;()
          if(a != null &amp;&amp; a.getMasterImage() != null){
          int number = a.getNoteNumber();
          imageParams.setMargins(25+45*number, a.getHeight(), 20, 360);
          frame.addView(a.getMasterImage(),imageParams);
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class note {
  private int noteNumber;
  private int height;
  private ImageView masterImage;
  public note(Context c){
      masterImage = new ImageView(c);
      masterImage.setImageResource(R.raw.zelda);
      this.noteNumber = 1;
      height = 0;
  }
  /**
   * @return the masterImage
   */
  public ImageView getMasterImage() {
      return masterImage;
  }
  /**
   * @param masterImage the masterImage to set
   */
  public void setMasterImage(ImageView masterImage) {
      this.masterImage = masterImage;
  }
  /**
   * @return the noteNumber
   */
  public int getNoteNumber() {
      return noteNumber;
  }
  /**
   * @param noteNumber the noteNumber to set
   */
  public void setNoteNumber(int noteNumber) {
      this.noteNumber = noteNumber;
  }
  /**
   * @return the height
   */
  public int getHeight() {
      return height;
  }
  /**
   * @param height the height to set
   */
  public void setHeight(int height) {
      this.height = height;
  }
  </code></pre>
  
  <p>}</p>