ListViews and Adapters

PDF for offline use
Sample Code:
Related Articles:
Related SDKs:

Let us know how you feel about this

Translation Quality


last updated: 2017-06

ListView is an important UI component of Android applications, used everywhere from short lists of menu options to long lists of contacts or internet favorites. It provides a simple way to present a scrolling list of rows that can either be formatted with a built-in style or customized extensively. A ListView instance requires an Adapter to feed it with data contained in row views. This document shows how to implement ListView and the different Adapter classes with Xamarin.Android. It also demonstrates how to customize the appearance of a ListView and discusses the importance of row re-use to reduce memory consumption. There is also some discussion of how the Activity Lifecycle affects ListView and Adapter use. For those working on cross-platform applications with Xamarin.iOS, the ListView control is structurally similar to the iOS UITableView (and the Android Adapter is similar to the UITableViewSource).


This article will take a comprehensive look at working with the ListView class and the different types of Adapter you can use with it. The discussion will begin with an overview of the ListView class itself before introducing progressively more complex examples of how to use it. The document structure is as follows:

  • Visual Appearance – Parts of the ListView control and how they work.

  • Classes – Overview of the classes used to display a ListView.

  • Displaying Data in a ListView – How to display a simple list of data; how to implement ListView's usability features; how to use different built-in row layouts; and how Adapters save memory by re-using row views.

  • Custom appearance – Changing the style of the ListView with custom layouts, fonts and colors.

  • Using SQLite – How to display data from a SQLite database with a CursorAdapter.

  • Activity Lifecycle – Design considerations when implementing ListView Activities, including where in the lifecycle you should populate your data and when to release resources.

Each section is accompanied by a sample code download.


Note: The RecyclerView widget is a more advanced and flexible version of ListView. Because RecyclerView is designed to be the successor to ListView (and GridView), we recommend that you use RecyclerView rather than ListView for new app development. For more information, see RecyclerView.


Part 1 - ListView Parts & Functionality

Part 2 - Populating a ListView With Data

Part 3 - Customizing a ListView's Appearance

Part 4 - Using CursorAdapters

Part 5 - Using a ContentProvider

Part 6 - ListView and the Activity Lifecycle


Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.