Decode Your Destiny
Find out what your name and birth date say about you and GET YOUR FREE REPORT

Simple ListView in Android

Android ListView is a graphical widget in Composite category. There are a various ways options to create Android ListView. We are going to create a very simple ListView by minimum effort.

Create an android project and with default values.

Here are the code:

package com.rahinur.example.simplelistview;

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

public class MainActivity extends ListActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] values = { "Windows", "Linux", "Unix", "Mac", "Android",
      "iOS", "BlackBerry" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
      android.R.layout.simple_list_item_1, values);
    setListAdapter(adapter);
  }

}

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *