Android: Changing image inside for loop without locking UI
<p>This is my code below.</p>

<pre><code>for(int k=1 ; k&lt;=1000; k++)
{
    if((k%2)==0)
        i.setImageResource(R.drawable.barbie2);
    else
        i.setImageResource(R.drawable.barbie3);

    try {
        Thread.sleep(1000);
    } catch(InterruptedException e) {
    } 
}
</code></pre>

<p>I want swap two images every 1 second without locking UI.
How can I do it in android please help me.</p>
