Configuring the CursorAdapter That Binds Database Data to the ListView
To display the Cursor
’s results in a ListView
we create a new CursorAdapter
object (lines 70–73) which exposes the Cursor
’s data in a manner that can be used by a ListView
. SimpleCursorAdapter is a subclass of CursorAdapter
that’s designed to simplify mapping Cursor
columns directly to TextView
s or ImagesView
s defined in your XML layouts. To create a SimpleCursorAdapter
, you first define arrays containing the column names to map to GUI components and the resource IDs of the GUI components that will display the data from the named columns. Line 70 creates a String
array indicating that only the "name"
column will be displayed, and line 71 creates a parallel int
array containing ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.