In our previous tutorial, we learned how to use a simple ListView in our Android project. But the problem is, what if we want to an add image or multiple TextView inside a single item? In this tutorial I am going to teach you how to create your own customized ListView.

In this tutorial we are going to make an application that will display list of companies such as Google, Facebook, Samsung and etc.. First we need to know how the items inside the ListView will look like. Let’s make it as simple as possible. I want to show their logo, their company name and a short description about them.

 

Before we start the tutorial, you need to download all the company logo we are going to use for this tutorial. You can download it here: Download Link

Create a new blank project in Android Studio then copy and paste all the images in your project’s drawable folder.

 

Now that we already know how the items will look like and we have all the assets needed, we can start by creating a new XML layout file under res/layout folder and name it custom_item.xml. Delete all the codes inside the custom_item.xml and copy the codes provided below.

 

Of course we need a listview in our main activity. Open activity_main.xml and include a listview just like what we did in our last tutorial or you can copy the codes provided below in your activity_main.xml.

 

Now create three more java classes just like in the image shown below.

 

Constants.java – We’ll place all constant information here such as company name, company logo and short descriptions.

CustomAdapter.java – Since we are going to create a custom listview, we also need to create a custom adapter that will bind the data to our listview. In our previous tutorial, we used the default array adapter and simply bind the string array but that won’t work here because our listview items have an image and two textviews.

CustomListItem.java – This will be a model class for listview items.

Now that I’ve explained the roles of each classes, open Constants.java then copy and paste the codes below.

 

Next, open CustomListItem.java then copy and paste the codes below.

 

Next, open CustomAdapter.java then copy and paste the codes below.

 

You can read more about BaseAdapter here: Base Adapter

Now open MainActivity.java then copy and paste the codes below.

 

Now you can run and test you app if it is working. The final output of this tutorial should be like this.

You can download the full source code here: Download Link