Android Working with ViewFlipper

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mahmood.a083.MainActivity">

    <TableLayout
        android:id="@+id/tableLayoutButtons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:stretchColumns="*">

        <TableRow android:orientation="horizontal">

            <Button
                android:id="@+id/buttonPrevious"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="Previous" />

            <Button
                android:id="@+id/buttonNext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="Next" />
        </TableRow>
    </TableLayout>

    <ViewFlipper
        android:id="@+id/viewFlipper"
        android:layout_above="@+id/tableLayoutButtons"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Start"
            android:gravity="center"/>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="center"
            app:srcCompat="@mipmap/cat1" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="center"
            app:srcCompat="@mipmap/cat2" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="center"
            app:srcCompat="@mipmap/cat3" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="End"
            android:gravity="center"/>
    </ViewFlipper>
    
</RelativeLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {

    ViewFlipper viewFlipper;
    Button buttonPrevious;
    Button buttonNext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewFlipper= (ViewFlipper) findViewById(R.id.viewFlipper);
        //viewFlipper.setInAnimation();
        //viewFlipper.setOutAnimation();
        //viewFlipper.setFlipInterval(1000);
        //viewFlipper.startFlipping();

        buttonPrevious= (Button) findViewById(R.id.buttonPrevious);
        buttonNext= (Button) findViewById(R.id.buttonNext);

        buttonNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewFlipper.showNext();
            }
        });

        buttonPrevious.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewFlipper.showPrevious();
            }
        });
    }
}

References
https://github.com/mhdr/AndroidSamples/tree/master/083
https://developer.android.com/reference/android/widget/ViewFlipper.html
https://www.youtube.com/watch?v=9xGIlaezMAU
https://www.youtube.com/watch?v=x5G2ejthdKM
http://abhiandroid.com/ui/viewflipper