Android - List View

Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.You can use this adapter when your data source is an array. By default, ArrayAdapter creates a view for each array item by calling toString() on each item and placing the contents in a TextView. Consider you have an array of strings you want to display in a ListView, initialize a new ArrayAdapter using a constructor to specify the layout for each string and the string array

Create a New Android Project

Open Android Studio and create a new Project to test ImageView UI Widget.

You can view this blog to know
how to create a Project in Android

Create XML Layout design

Open activity_main.xml from android resources and remove everything.Drag an Relative Layout and then drag a TextView on Layout in Graphical mode of IDE.

	<RelativeLayout xmlns:android=""
    tools:context="dzone.jaipur.myapp1.MainActivity" >

  < ListView
        android:layout_height="wrap_content" >

Your Activity Class (Java File) stored in Src->Your package Name->
Put the code in your java File (Android Activity).

public class MainActivity extends AppCompatActivity {

 String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry",
            "WebOS","Ubuntu","Windows7","Max OS X"};

	protected void onCreate(Bundle savedInstanceState) {

  ArrayAdapter adapter = new ArrayAdapter(this,
                R.layout.activity_listview, mobileArray);

        ListView listView = (ListView) findViewById(;



Now Run the Application by upper toolbar green triangle then select your device and get the desired output.

Why Us?


  • 257,katewa nagar,gujjar ki thadi,new sanganer road, Jaipur, Jaipur
  • Phone:+919829708506
  • Email:[email protected]

Follow Us