In this post we are going to create a simple custom ListView. This post is very simple and for beginners.

Start your New Android Project

1. Create a new project in Eclipse from File ⇒ New ⇒ Android Application Project. I had left my main activity name as .

2. Now open your activity_main.xml inside res ⇒ layout folder and insert ListView from Composite inside Palette to your activity_main.xml

3. Now create new  XML file inside res ⇒ layout folder da_list.xml and add TextView in it.

4. Now open your inside src ⇒  In this file we can insert data to ListView and handel click when user press on a list.

In create two method

 In listviewload()  we load the data into listview and show and in 2nd method handelClick() we handle user click.

listviewload() Method:

In  this method first we create  array string in which we are going to show in listview, after this we use array adapter. In ArrayAdapter we pass three parameter

ArrayAdapter<String>(Context context, Resource,  ArrayData);

after that we set adapter data to ListView.


handleClick() Method:

In this method we handle user click on list and open new activity. You need to create new xml file inside layout folder


Now when user click on a particular list we open activity according to ListItem. We use setOnItemClickListener() to handle user  click.

Create new java file inside src folder name as this is the file we open when user click on list.

You also need to add this activity entry in manifest file.

You can try this code and also download file from above download link.