Android Studio Swipe Pull ListView

In this Android Studio article i want to show Swipe Pull ListView.

 

So now lets get started

 

First of all create a new project in your Android Studio, after that for this project we need some classes.

 

 

1:  The first class is a Name class it is a POJO class

 

 

 

What Is POJO Class ? 

POJO stands for Plain Old Java Object, and would be used to describe the same things as a “Normal Class” whereas a JavaBean follows a set of rules. Most commonly Beans use getters and setters to protect their member variables, which are typically set to private and have a no-argument public constructor

 

 

2: After that you need to copy some images to your drawable folder

 

3: Now we need to do programming of our main_layout.xml and also our model.xml class this is our main_layout.xml, in this file we add SwipeRefreshLayout with a ListView. it looks like this .

 

 

 

Also this is our model.xml file,  we create a custom model for our ListView and we add an ImageView with TextView in this file.

 

 

 

4: After that we are going to create our MyViewHolder class that holds our views of our model like TextView and ImageView.

 

 

 

5:  And this class is our CustomAdapter class

 

You can see in the above class we have extended this class from the BaseAdapter and also we have created a Context and also an ArrayList type of Name. also after extending from the BaseAdapter you need to implement some methods.

 

this method returns our list objects.

 

 

in this method we get the list object at specific position.

 

 

 

 

this is for getting the id of list element.

and last one is for getting and inflating the views

 

 

6: This class is our MainActivity.java class

 

 

7: This is our interface for handling the click event on each row items of listview

 

 

 

Summary :

  • Create Project In Android Studio
  • Design Your main_activity.xml
  • Create Your model.xml
  • Create Name POJO class
  • Create  CustomAdapter class
  • Create MyViewHolde class
  • Create ItemClickListener Interface
  • Do Some Coding in the MainActivity.java class

 

 

 

 

 

So run the code and this will be the result

Android Studio Swipe Pull Refresh Layout
Android Studio Swipe Pull Refresh Layout

 

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×