How do I bind information from my database to a TextView? The ListView Isnt showing the information from the Cursor. Do I need to use the adapter I have created?
I'm trying to display the results in TextViews withing the List.
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.contactform);
Cursor cursor = getCursor();
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
this, //Context
R.layout.contactform, //xml definintion of each listView item
cursor, //Cursor
new String[] {"FirstName", "LastName", "Phone", "Email"}, //Columns to select From
new int[] {R.id.contact_firstname, R.id.contact_lastname, R.id.contact_phone, R.id.contact_email} //Object to bind to
);
}
private Cursor getCursor()
{
String TABLE_NAME = "exampleContacts";
String[] FROM = {"_id", ""FirstName", "LastName", "Phone", "Email"} ;
dbManager = new DatabaseManager(this);
SQLiteDatabase db = dbManager.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, FROM, "ContactID=?", new String[] {PrContactID}, null, null, null);
startManagingCursor(cursor);
return cursor;
}
The reason it wasnt being mapped to the ListView is because
setListAdapter();wasnt being used.