Can you loop a flipper animation based on users entry?
<p>In the example below there is layout with an entry field and button. The user would enter a number between 0 and 10 and the flipper would animate from screen 10 to the number entered. </p>

<p>If I comment out the <b>for(int i=10; .....;i--){ </b>on the onClick the screens slides fine each time you click the button. If I put in the for loop in the screen goes straight to the screen number without sliding each screen. The loop goes too fast for the animation to catchup. </p>

<p>Is it possible to have it so that if you enter 2 for example the flipper would go:</p>

<p>Flipper 10 </p>

<p>Slide animation occurs</p>

<p>Flipper 9</p>

<p>Slide animation occurs</p>

<p>Flipper 8
  .....</p>

<p>main activity:
<code></p>

<pre><code>package com.jk.flippertest;

import com.jk.flippertest.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

public class FlipperTestActivity extends Activity {
/** Called when the activity is first created. */
private Animation slideRightIn;
private Animation slideRightOut;
private ViewFlipper viewFlipper;
TextView loopNumber;
int loopValue;
Button goBtn;
ViewFlipper fSpace;
LayoutInflater inflater;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    loopNumber = (TextView)findViewById(R.id.editText1);
    goBtn = (Button)findViewById(R.id.button1);       

    fSpace = (ViewFlipper)findViewById(R.id.viewFlipper1);
    inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    for (int i=0;i&lt;11;i++){
        TextView tvi = new TextView(this);
        tvi.setText("Flipper "+i);
        tvi.setTextSize(50);
        tvi.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        LinearLayout lli = new LinearLayout(this);
        lli = new LinearLayout(this);
        lli.setOrientation(LinearLayout.VERTICAL);
        lli.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        lli.addView(tvi);

        fSpace.addView(lli);
        }

        viewFlipper = (ViewFlipper)findViewById(R.id.viewFlipper1);
        slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
        slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);

        goBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                Toast.makeText(getBaseContext(), "Value is "+loopNumber.getText(), Toast.LENGTH_LONG).show();
                for(int i=10;i&gt;=Integer.parseInt(loopNumber.getText().toString());i--){
                viewFlipper.setInAnimation(slideRightIn);
                viewFlipper.setOutAnimation(slideRightOut);                     
                viewFlipper.showPrevious();
                }
            }
        });

}
</code></pre>

<p>}</p>

<p></code></p>

<p>main layout:</p>

<p><code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;
    &lt;EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" android:hint="Enter numb between 0 to 10."&gt;
        &lt;requestFocus /&gt;
    &lt;/EditText&gt;

    &lt;Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Go" /&gt;

    &lt;ViewFlipper
        android:id="@+id/viewFlipper1"
        android:layout_width="match_parent"
        android:layout_height="fill_parent" &gt;
    &lt;/ViewFlipper&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p></code></p>

<p>slide_right_in.xml</p>

<p><code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="800"/&gt;
&lt;/set&gt;
</code></pre>

<p></code></p>

<p>slide_right_out.xml
<code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="800"/&gt;
&lt;/set&gt;
</code></pre>

<p></code></p>
