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);
  }

}

Expert in Oracle Database 10g and 11g. Deep knowledge on SQL, PL/SQL and Java programming. Working at Square InformatiX Limited as Oracle Database Administrator.

Posted in Android Tagged with: ,
One comment on “Simple ListView in Android
  1. Jong Bum Kim says:

    Thank you. Very simple sample.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>