title: Using a for loop to set image resources for multiple image views
body: <p>I am trying to use a for loop to set image resources for several image views. I know the solution i have come up with wont work and i know why. My question is what can i use instead of this? Just to make it clear only some of the images will be updated depending on what the areasArray contains. e.g. 4,7,9 this means only images iv_4, iv_7, iv_9.</p>
  
  <pre><code>        iv_0 = (ImageView) ViewLameness.findViewById(R.id.iv_0);
      iv_1 = (ImageView) ViewLameness.findViewById(R.id.iv_1);
      iv_2 = (ImageView) ViewLameness.findViewById(R.id.iv_2);
      iv_3 = (ImageView) ViewLameness.findViewById(R.id.iv_3);
      iv_4 = (ImageView) ViewLameness.findViewById(R.id.iv_4);
      iv_5 = (ImageView) ViewLameness.findViewById(R.id.iv_5);
      iv_6 = (ImageView) ViewLameness.findViewById(R.id.iv_6);
      iv_7 = (ImageView) ViewLameness.findViewById(R.id.iv_7);
      iv_8 = (ImageView) ViewLameness.findViewById(R.id.iv_8);
      iv_9 = (ImageView) ViewLameness.findViewById(R.id.iv_9);
      iv_10 = (ImageView) ViewLameness.findViewById(R.id.iv_10);
      iv_11 = (ImageView) ViewLameness.findViewById(R.id.iv_11);
      iv_12 = (ImageView) ViewLameness.findViewById(R.id.iv_12);
      iv_13 = (ImageView) ViewLameness.findViewById(R.id.iv_13);
  
      for (int i = 0; i &lt; areasArray.length; i++) {
  
          int[] images = { R.drawable.f0sc, R.drawable.f1sc, R.drawable.f2sc,
                  R.drawable.f3sc, R.drawable.f4sc, R.drawable.f5sc,
                  R.drawable.f6sc, R.drawable.f7sc, R.drawable.f8sc,
                  R.drawable.f9sc, R.drawable.f10sc, R.drawable.f11sc,
                  R.drawable.f12sc, R.drawable.f13sc };
  
          String image = "iv_" + areasArray[i];
  
          image.setImageResource(images[i]);
  
      }
  </code></pre>