In this tutorial, I can explain to you how we can add image slider in Android Application. For this tutorial, I am using an image slider plugin developed by Shivam Srivastava.

To implement image slider in your Android Application follow below simple steps. Implementation of image slider is very easy and also I am loading an image from the server using OKHTTP3. If you did not read my last post in which I explain how we can send and get data using OKHTTP3 you can read that from this link.

Step 1. Create a new Android project (In my case my project name is AndroidImageSlider).

Step 2. Add library OKHTTP3 and ImageSlider in your build.gradle(App) and add code in dependencies as shown below

Step 3. Once we add our dependencies and synchronize our project we are ready to code our application. Now open your AndroidManifest.xml and add Internet permission.

Step 4. Now we can create a Package name model in which we can create BannerModel(getter and setter) class which hold id and image URL which we load for the server using web API.

Step 5. Now open the activity_main.xml file and we call our image slider view here as shown below

Step 6. Now in our MainActivity.java class, we first find or our ImageSlider and after that, we can load data from API and set that data into Adapter and we also create Fragment inside or MainActivity Class as shown in below code.

Here is code for the fragment_main3.xml file which holds ImageView for Slider.

You can download code from the above download link. Hope this post helps you.