I am developing an application in which I use ViewFlipper with a custom implementation of OnTouch . In ViewFlipper , I have about 20 images to scroll ViewFlipper . This works great, but if I'm on the 20th image in the series and flip the screen, it goes back to the first image.
I want the ViewFlipper not to return to the first image. Instead, he should just dwell on the last image.
Here is my code:
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; public class Activity1 extends Activity implements OnTouchListener{ float downXValue; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
And the XML layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/layout_main" > <ViewFlipper android:id="@+id/details" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/two" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/three" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/four" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/five" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/six" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/seven" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:background="@drawable/eight" android:layout_x="1dip" android:layout_y="1dip" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView> </LinearLayout> <ViewFlipper> </LinearLayout>
source share