title: Changing images using for loop
body: <p>How to change an image to the next one in the array using a for loop, once a button has been clicked. At present I have this in my on click method.</p>
  
  <pre><code> int[] Pics = {R.drawable.pic1, R.drawable.pic2, R.drawable.pic3};
  
   for (int i=0; i&lt;Pics.length; i++){
  
       mainpic.setImageResource(Pics[i]);
  
   }
  </code></pre>
  
  <p>The problem is when the next button is clicked, it only stays at the first image or goes straight through to the last image.</p>