title: Android - Loading images with a delay
body: <p>I'm trying to fake some kind of progress bar. I have X images and want an <code>ImageView</code> to show them with a certain delay.</p>
  
  <p>I've tried to do something like this:</p>
  
  <pre><code>for(i=2;i&lt;X;i++) 
  {
          Handler handler = new Handler();
          handler.postDelayed(new Runnable() {  
  
                @Override
                public void run() {
  
                 drawable = getResources().getDrawable(getResources()
                                  .getIdentifier("img_"+i, "drawable", getPackageName()));
  
                 imgPayment.setImageDrawable(drawable);
                 }}, DELAY);                  
  }
  </code></pre>
  
  <p>But the for loop doesn't wait for the <code>run()</code> to end. I just see the first and last image. I tried a few other things but couldn't get the desired results.</p>