Pr.Pg Next Pg

ListView tutorials


What is a List View

  • ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

  • Following is an example of how a Simple List View looks like:



  • Individual list item can be selected, this selection can update the ActionBar or can trigger a detailed screen for the selection.

  • Android provides the ListView class which is capable of displaying a scrollable list of items. These items can be of any type.



  • An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. The Adapter provides access to the data items. The Adapter is also responsible for making a View for each item in the data set.

  • Adapters are used to provide the data to the ListView object. The adapter also defines how each row is theListView is displayed.

  • An adapter extend the BaseAdapter class. Android provides some standard adapters; the most important areArrayAdapter and CursorAdapter.

  • ArrayAdapter can handle data based on Arrays or java.util.List.

  • SimpleCursorAdapter can handle database related data. This description focuses on the non database case.



  • An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.

  • ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or listif it's in code).

  • If the main purpose of a screen (Activity) in your mobile application is to present a list of choices or content to the user, use ListActivity instead of Activity.


Pr.Pg border                                              Next Pg