Android AdapterViewFlipper Example using Retrofit and Glide

Hello guys in Android AdapterViewFlipper Example, we will learn using Android AdapterViewFlipper. We will use Retrofit to fetch data from a URL and we will also use Glide to load images from URLs. So lets begin with our Android AdapterViewFlipper tutorial.

What is Android AdapterViewFlipper?

AdapterViewFlipper is a UI element that can be used for switching views. We can create slider like things by using AdapterViewFlipper.

You can see a very simple example of android AdapterViewFlipper below.

Android AdapterViewFlipper Example

Our Web Service

  • I have a URL that is fetching me the data.

  • The above URL is returning the following data.

  • So we have name and imageurl. For fetching this data in android side we will use Retrofit and to load the image we will use Glide.

Creating a new Project

  • Create a new Project with an Empty Activity using Android Studio.
  • Now once the project is loaded add Retrofit, Gson and Glide to it.

Adding Dependencies

  • As we have to use Retrofit and Glide. Add the following lines inside your app level build.gradle.

  • Now sync your project with gradle.

Defining Retrofit Models

  • According to the JSON response we are getting we will need two models for Retrofit API.
  • First will store our hero. So create a class named and write the following code.

  • As the response contains a list of heroes, we need one more model class to store all the heroes in an ArrayList so create a class named and write the following code.

  • The models are ready now we will define the Retrofit service.

Creating Retrofit Service

  • Create an interface named and write the following code.

  • The retrofit API is also ready. Now lets finally build our Android AdapterViewFlipper.

Creating AdapterViewFlipper

Creating Layout

  • Open activity_main.xml and add an AdapterViewFlipper .

Creating Layout for AdapterViewFlipper

  • We also need a layout for the screen of AdapterViewFlipper so create a file named flipper_items.xml inside layout directory and write the following xml code.

  • Now we will build the Adapter for our AdapterViewFlipper.

Creating Adapter

  • Create a class named and write the following code.

Fetching Data using Retrofit and Displaying it on AdapterViewFlipper

  • Now come to and write the following code.

  • Now run your application and you will see your AdapterViewFlipper the same as you seen in the video demo.
  • If you are having problems building it you can try my source code. You can get my source code from below link.

So thats all for this Android AdapterViewFlipper Example. If you found it helpful please share it on your social networks. Also if you are having any confusions or queries lets discuss it on comments below. Thank You 🙂

7 thoughts on “Android AdapterViewFlipper Example using Retrofit and Glide”

  1. how to make an adapter or an android app offline that in array adapter we click and and another activty opens how we can make this type of app offline plz reply or tell any tutotial link thanks


Leave a Comment