I currently have an application that contains a listView that is populated from the sqlite database. The ListView contains two texts views for each item, one for the name and one for the status. A status is displayed either by a 0 or a 1 like true or false. I would like to make each item that contains the number 0 or 1 as the status to display open or closed.
methods for the listview:
// Return all data in the database.
public Cursor getAllRows() {
String where = null;
Cursor c = ourDatabase.query(true, DATABASE_TABLE, ALL_KEYS, where,
null, null, null, null, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
// also added
// Get a specific row (by rowId)
public Cursor getRow(long rowId) {
String where = KEY_ROWID + "=" + rowId;
Cursor c = ourDatabase.query(true, DATABASE_TABLE, ALL_KEYS, where,
null, null, null, null, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
Here is my listView code:
private void loadListView() {
// TODO Auto-generated method stub
Locker getList = new Locker(this);
getList.open();
Cursor cursor = getList.getAllRows();
startManagingCursor(cursor);
// setup mapping
String[] fromFieldNames = new String[] { getList.KEY_LOCKERNUMBER,
getList.KEY_STATUS };
int[] toViewIDs = new int[] { R.id.tvLockerNumber, R.id.tvSatus };
// create adapter
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this,
R.layout.itemlayout, cursor, fromFieldNames, toViewIDs);
// set the adapter
ListView myList = (ListView) findViewById(R.id.lvInfo);
myList.setAdapter(myCursorAdapter);
}
How can I go about doing this?