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]
SpinnerAdapter adapter = new SimpleCursorAdapter (this,
// Use a template that displays a text view
Android. R. layout. simple_gallery_item,
// 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 });
Gallery g = (Gallery) findViewById (R. id. gallery );
G. setAdapter (adapter );
SpinnerAdapter adapter = new SimpleCursorAdapter (this,
// Use a template that displays a text view
Android. R. layout. simple_gallery_item,
// 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 });
Gallery g = (Gallery) findViewById (R. id. gallery );
G. setAdapter (adapter );
In this example, the View used by the Adapter is TextView (id is android. R. id. text1), so Gallery displays the contact's name.
Author: mapdigit