How to control ontouch fuctionality in android?
<p>I am making an android appication in which I have put 10 images and put ontouch functionality on it but whenever I reached on 10th image it is still working and get back  to 1st image. 
I want to stop the ontouch functionality on 10th image or last image.</p>

<p>Anyone know about this functionality? please help me.</p>

<p>thanks alot.</p>

<p>here is java code
ackage com.warriorpoint.taxman3;</p>

<p>import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.ViewFlipper;</p>

<p>public class Activity1 extends Activity implements OnTouchListener{</p>

<pre><code>float downXValue;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set main.XML as the layout for this Activity
    setContentView(R.layout.main);

    // Add these two lines
    LinearLayout layMain = (LinearLayout) findViewById(R.id.layout_main);
    layMain.setOnTouchListener((OnTouchListener) this); 

    // Add a few countries to the spinner
    Spinner spinnerCountries = (Spinner) findViewById(R.id.spinner_country);
    ArrayAdapter countryArrayAdapter = new ArrayAdapter(this,
                android.R.layout.simple_spinner_dropdown_item,
                new String[] { "Canada", "USA" });
    spinnerCountries.setAdapter(countryArrayAdapter);

}

public boolean onTouch(View arg0, MotionEvent arg1) {

    // Get the action that was done on this touch event
    switch (arg1.getAction())
    {
        case MotionEvent.ACTION_DOWN:
        {
            // store the X value when the user's finger was pressed down
            downXValue = arg1.getX();
            break;
        }

        case MotionEvent.ACTION_UP:
        {
            // Get the X value when the user released his/her finger
            float currentX = arg1.getX();            

            // going backwards: pushing stuff to the right
            if (downXValue &lt; currentX)
            {
                // Get a reference to the ViewFlipper
                 ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                 // Set the animation
                  vf.setAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out));
                  // Flip!
                  vf.showPrevious();
            }

            // going forwards: pushing stuff to the left
            if (downXValue &gt; currentX)
            {
                // Get a reference to the ViewFlipper
                ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                 // Set the animation
                 vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
                  // Flip!
                 vf.showNext();
            }
            break;
        }
    }

    // if you return false, these actions will not be recorded
    return true;
}
</code></pre>

<p>}
here is xml code

</p>

<pre><code>&lt;ViewFlipper android:id="@+id/details"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;  




     &lt;LinearLayout
           android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        &gt;

        &lt;ImageView android:id="@+id/ImageView01" android:background="@drawable/eea" 
        android:layout_x="1dip" android:layout_y="1dip" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"&gt;&lt;/ImageView&gt;
    &lt;/LinearLayout&gt; 

    &lt;LinearLayout
           android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        &gt;

        &lt;ImageView android:id="@+id/ImageView01" android:background="@drawable/ef" 
        android:layout_x="1dip" android:layout_y="1dip" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"&gt;&lt;/ImageView&gt;
    &lt;/LinearLayout&gt; 

    &lt;LinearLayout
           android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        &gt;

        &lt;ImageView android:id="@+id/ImageView01" android:background="@drawable/eg" 
        android:layout_x="1dip" android:layout_y="1dip" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"&gt;&lt;/ImageView&gt;
    &lt;/LinearLayout&gt; 

    &lt;LinearLayout
           android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        &gt;

        &lt;ImageView android:id="@+id/ImageView01" android:background="@drawable/eh" 
        android:layout_x="1dip" android:layout_y="1dip" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"&gt;&lt;/ImageView&gt;
    &lt;/LinearLayout&gt; 


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

<p></p>

<p>I had use View flipper in my code and then add the images on it.</p>
