Auto Image Slider with ViewFlipper – Android Studio Tutorial

Google+ Pinterest LinkedIn Tumblr +

Video is ready, Click Here to View ×


►Twitter:
►Instagram:
►Facebook:

►Download my Game here:

In this tutorial you will learn how to make auto image slider with ViewFlipper

Share.

About Author

24 Comments

  1. my image is not flipping. I have used a fragment
    here is my code

    public class fragment_home extends Fragment {

    ViewFlipper v_flipper;

    ViewGroup view;

    @Nullable

    @Override

    public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    view=(ViewGroup)inflater.inflate(R.layout.fragment_home, container, false);

    return view;

    }

    @Override

    public void onActivityCreated(Bundle savedInstanceState) {

    super.onActivityCreated(savedInstanceState);

    v_flipper= view.findViewById(R.id.v_flip);

    int images[] = {R.drawable.s1, R.drawable.s2, R.drawable.s3, R.drawable.s4, R.drawable.s5, R.drawable.s6, R.drawable.s7, R.drawable.s8, R.drawable.s9};

    for (int image : images)

    {

    flipperImages(image);

    }

    }

    public void flipperImages(int image)

    {

    ImageView imageView=new ImageView(getActivity().getApplicationContext());

    imageView.setBackgroundResource(image);

    v_flipper.addView(imageView);

    v_flipper.setFlipInterval(2000);

    v_flipper.setAutoStart(true);

    v_flipper.setInAnimation(getActivity().getApplicationContext(),android.R.anim.slide_in_left);

    v_flipper.setOutAnimation(getActivity().getApplicationContext(), android.R.anim.slide_out_right);

    }

    }