Android App Bar Text Search for ListView – Example

In this tutorial we are going to show you how to implement custom ListView in Android with search bar to search and filter contents of list.

 For this tutorial we are going to use response from below REST api to show on our android app.
Sample Response:


APP Demo:


Creating New Project:

  1. Create a new project in your Anroid Studio and Go to File => New Project
  2. Fill in all the details and select Basic Activity template.

app_bar_main.xml – Modify and add Search box in action bar


content_main.xml Using RecyclerView will create list or rows


Next step is to design single item for our list. Create a new XML file under layout folder and name it as project_list_view.xml.
Right Click ⇒ New ⇒ Android XML File

In this tutorial I designed custom list using CardView to display all project details.

project_list_view.xml Creates layout for individual items in the list



Until now we have completed designing part of our app. Now we will write code to read JSON data
from REST api and parse it to display in our list row. Create a new java class file in your
src folder. Right Click on src ⇒ New ⇒ Class and name it as



Now we will create POJO class to map data from REST response to java class. Create a new java class file in your
src folder. Right Click on src ⇒ New ⇒ Class and name it as



Now open your MainActivity class and add below code. In the below code I am getting json response from url and parsing it.

We are using GetKickStartProjects class to read data from REST api on AsynchTask. AsyncTask enables proper and easy use of the UI thread. This class allows you to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.


Add Permissions in AndroidManifest.xml

Open your AndroidManifest.xml file add INTERNET permission.


Final Output:

Finally you should see below output




Download sample code here



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Notify of