Android Image Slider Using ViewPager Example

In this tutorial you will learn to make android image slider using ViewPager and PagerAdapter.

ViewPager is a layout manager that allows the user to flip left and right through pages of data. We supply an implementation of a PagerAdapter to generate the pages that the view shows.

Below example shows how to make a simple image slider in android.

Demo

Android Image Slider Using ViewPager Example (Demo)

Android Image Slider Using ViewPager Example

Create an android studio project with package name com.androidimageslider.

Here I have used total 4 pages in slider. So paste some images in res/drawable folder.

Add following code in respective files.

res/layout/activity_main.xml

res/layout/item.xml

src/MainActivity.java

src/MyCustomPagerAdapter.java

Save and run the project.

Screenshot

Android Image Slider Using ViewPager Example

Comment below if you have any doubts regarding above android image slider tutorial.

3 thoughts on “Android Image Slider Using ViewPager Example

  1. priya sharma

    how to set image slider picture change automatically after some delay

    Reply
  2. Tejas Gawali

    Hi Neeraj Mishra Very nice article helpful can you help me with 3 sec timer automatic silder.

    thanks.

    Reply
  3. Abhishek sharma

    when i run the app then it show this error
    Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *