How to pause but not freeze Android execution?
<p>I'm trying to set the background color of an ImageView over a specified amount of time (pauses in between each switch of color) based on a certain criteria (such as string = "a" or "b"). My problem is I can't seem to make the entire application wait for one change until it moves on to the next, so to the user it just looks like the color starts then is immediately the last color.  </p>

<p>I've tried CountDownTimers (which just continue to execute while the other timer is running), handlers (postDelayed(null, 5000)), Thread.Sleeps etc.  </p>

<p>Here's an example of what I'm trying to do:  </p>

<p>Set color on ImageView to red<br>
sleep for 500ms  </p>

<pre><code>for(int i = 0; i &lt; stringArray.length; i++){  
    if(stringCompare = "a") {  
    Set color on ImageView to blue  
    sleep for 500ms }  
else if(stringCompare = "b") {  
    Set color on ImageView to blue  
    sleep for 1000ms  
  }  
Set color on ImageView to red  
sleep for 500ms  
}  
</code></pre>

<p>I know that's kind of crazy, but I've tried all the above methods I could think of with no success on actually making the program wait, but not completely stopping it.    </p>

<p>Thanks.</p>
