Add delay to While loop for animation to complete
<p>The SwipeSample I'm using has an animation xml that slides the layouts for left to right etc. There is a duration set to 800 on each of the animations. </p>

<p>I have a while loop that checks what position the user clicks on and then loops the animation to complete the loop.</p>

<p>What I'm finding is that if I'm at current position of 1 and I want to go to 0 the animation works fine. If I'm at position 6 and want to go to 0 the layouts seems to slide over in one hit the loop does not allow the animation time to play before each pass.</p>

<p>Is it possible to add a delay to a while loop or should I be using another approach?</p>

<p>This is the code:</p>

<p>case R.id.EditTYellow:
            System.out.println("Text Yellow pressed");</p>

<pre><code>        if(viewFlipper.getDisplayedChild()!=0 || viewFlipper.getDisplayedChild()&gt; 0 ){
            do  
             { 
            viewFlipper.setInAnimation(slideRightIn);
            viewFlipper.setOutAnimation(slideRightOut);
            viewFlipper.showPrevious();
            //Delay need here to allow animation to complete
             } while (viewFlipper.getDisplayedChild()!=0);
        }                       
        //System.out.println("New Flipper "+viewFlipper.getDisplayedChild());
    break;
</code></pre>

<p>I've tried adding a Thread.sleep(800) but it did not seem to work.</p>

<pre><code>            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
</code></pre>
