The constructor of SimpleCursorAdapter is as follows:
Public SimpleCursorAdapter (Context context, int layout, Cursor c, String [] from, int [])
Context: context object. You can use activity.
Layout: layout resource ID simple_gallery_item.xml
Cursor: cursor object. In this example, it is the address book cursor.
From: array of column names to be displayed
To: id of the View corresponding to the column
[Java]
// Get a cursor with all people
Cursor c = getContentResolver (). query (People. CONTENT_URI,
Null, null );
StartManagingCursor (c );
ListAdapter adapter = new SimpleCursorAdapter (this,
// Use a template that displays a text view
Android. R. layout. simple_list_item_1,
// Give the cursor to the list adatper
C,
// Map the NAME column in the people database...
New String [] {People. NAME },
// The "text1" view defined in the XML template
New int [] {android. R. id. text1 });
SetListAdapter (adapter );
// Get a cursor with all people
Cursor c = getContentResolver (). query (People. CONTENT_URI,
Null, null );
StartManagingCursor (c );
ListAdapter adapter = new SimpleCursorAdapter (this,
// Use a template that displays a text view
Android. R. layout. simple_list_item_1,
// Give the cursor to the list adatper
C,
// Map the NAME column in the people database...
New String [] {People. NAME },
// The "text1" view defined in the XML template
New int [] {android. R. id. text1 });
SetListAdapter (adapter );