Thursday, February 9, 2023

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.

Mobile App Development Services

Mobile App Development Services

Mobile App Development - Android mobile application developer - Android Mobile app development - Android Mobile app for your business - Mobile Application development...
15 Upbeat IDE for developing Android App

15 Upbeat IDE for developing Android App

IDE for developing android Application abbreviated as Integrated development environment popularly used as IDE is a platform or I can say a helper which...
Enable WhatsApp Payment

How to Enable WhatsApp Payment

WhatsApp Pay has finally been given regulatory approval by the National Payments Corporation of India (NPCI), according to a report by Business Standard. The...
WhatsApp Payment Launch in Brazil

WhatsApp Payment Launch in Brazil

Facebook's WhatsApp messaging service rolled out a system across Brazil on Monday that will allow users to send money to individuals or local businesses...
Enable Notifications OK No thanks