Download Code

Android Studio Listview Example Android

In Android Studio Listview example android tutorial you will learn how to use ListView in android application.Listview is mostly used to display list of avialable items within any ecommerce app.


List View is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter.

Array Adapter

A concrete BaseAdapter that is backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource.

Create new android studio listview example android application project.

Drag and Drop List View in activity_main.xml file.


Android Studio Listview,android studio listview example,android studio listview example android,listview example android,

Go to your class.

  • Create variable of ListView.
  • Create String array.
  • Refer id of List View.
  • Store string array in ArrayAdapter.
  • Set ArrayAdapter to List View.
  • Apply click event on list view items.
  • Display Toast to show which item is clicked.

package com.example.anonymous.studiolistview;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    ListView codecList;   // list view variable
    // string array for list menu
    String androidCodec[] = {"Java","C#","C++","Php","Javascript","Android","Codec"};
    protected void onCreate(Bundle savedInstanceState) {
        codecList = (ListView) findViewById(;   // refering list view of xml
        //setting array adapter with item layout
        ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, androidCodec);
        codecList.setAdapter(adapter);   // setting adapter to list view
        // click event on list view items
        codecList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


Deploy your android application project.It will display a listview containing string array which you initialized at the start.When you click on any list item.It will display that item text in Toast.

Android Studio Listview,android studio listview example,android studio listview example android,listview example android,

That’s it for this tutorial.