Subscribe for notification
Categories: Android Tutorial

How to implement simple ListView in android

How to implement simple ListView in Android

Here I am going to show you how to implement simple ListView in android. First of all, you need to know what is list view and how it works in android then we will move towards the implementation.

What is ListView :

List view is a list of items having the same view or you can say the presentation. In android, Adapter is used to hold the list item which then binds items to the listview. Adapter fetches the data from the data source like the array or from the cursor which stores the result of the database query. Now we will see the actual implementation of a list view.

Implement simple ListView in android :

To implement simple listview in android follow the below steps :

  1. Create the new project in Android Studio as File ->New-> New Project.
  2. Name your project whatever you want and rename MainActivity as SimpleListViewActivity then select Finish.
  3. We want data that will display in list view, here I am using an array as a data source. Create string array inside res -> values-> string.xml as below.
    <string name="app_name">ListViewExample</string>

    <string-array name="types_of_os">
        <item>Android OS (Google Inc.)</item>
        <item>Bada (Samsung Electronics)</item>
        <item>BlackBerry OS (Research In Motion)</item>
        <item>iPhone OS / iOS (Apple)</item>
        <item>MeeGo OS (Nokia and Intel)</item>
        <item>Palm OS (Garnet OS)</item>
        <item>Windows Mobile (Windows Phone 7)</item>
  1. Create the layout for the single item of a list. res » layout » right click » Layout resource file » give a name listview_item.xml then press OK.
  2. Copy the below code to the listview_item.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    android:orientation="vertical" android:layout_width="match_parent"


  1. Now open SimpleListViewActivity from java package and copy the below text.
package com.buzzmycode.listviewexample;

import android.os.Bundle;
import android.widget.ArrayAdapter;

public class SampleListViewActivity extends ListActivity {

    protected void onCreate(Bundle savedInstanceState) {

        String[] mobile_os = getResources().getStringArray(R.array.types_of_os);
        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.listview_item,, mobile_os));

  1. Finally, Open your AndroidManifest.xml from a manifest package and add make changes to your AndroidManifest file as below.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

        <activity android:name=".SampleListViewActivity">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

  1. Now run your project you will see the output as shown below.
Simple ListView in Android

I hope this would have helped you. For any query you can comment below, I am always ready to help you.


SyncSaS Technologies is specialized in creating and designing customized software. We have our own team that will be in charge of developing your softwares.

Published by

Recent Posts

Adsense Updated Dashboard

Changes in Adsense Dashboard Recently you might have seen few changes in Adsense dashboard, these…

3 weeks ago

Guide Book For Google Adsense

With my experience in working as AdSense publisher, I have written many articles, tutorials for…

3 weeks ago

How to manage Google Adsense to get High CPC

Manage Adsense for High CPC CPC (Cost per click) in simple words the CPC is…

3 weeks ago

Google Adsense Introduce page level ads

If you are already the publisher of Google Adsense account then now its time to…

3 weeks ago