Android Basics – Learn how to use Adapter with ListView

In the last Post you learnt about the ListActivity class. In this Tutorial I want to introduce you to Adapters and how to use them with ListView.

Adapters are used to bind or connect View with Data Source. Now a data source can be an array, a database or a web service.

An ArrayAdapter enables us to work with Arrays. Creating one is pretty simple.

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, colors);

You can follow along with me in the Video above to understand about Adapters.

Source code can be found here

Android Basics – Learn how to use a ListActivity to display and manage a List of Items


In the last Post you got familiar with using a ListView to display a list of items which came from a static String Array.

You can also accomplish the same using a ListActivity.

Why use ListActivity ?

A ListActivity class is quite useful as you don’t need to create a Layout file.

You have the option to create your own Layout file, but it’s not mandatory.

Also you don’t need to create an Event Listener. In order to use the ListActivity you will need to extend this class.

public class ScrollingActivity extends ListActivity {

protected void onCreate(Bundle savedInstanceState) {


Follow the Video in which I will guide you to create a new ListActivity to display the items.

Source Code is available here

Android Basics – Learn about Event Listeners. How ListView Item Click Works ?

In the last Article you learnt about ListView and how it can be used to display a List of items.

So the list of items is ready, what’s next ?

Don’t you think the user should be able to do something with that. Like view the details of an item.

To enable the App to perform some activity when an item is clicked you need to use an onItemClickListener.

Source Code is available here


Android Basics – Learn how to display a List of Items using List View

ListView comes handy when you want to display a List of items.

Consider an App which allows you to view a list of latest Mobile Phones. Now in order to display this list you can use ListView.

The data for the list can come from some Database, an Array or a Web Service. For now we will use a String Array for this List.

Follow along to learn about ListView.

Source Code available here