Hallo, wer kann mir sagen wie ich den folgenden text so umstellen kann, dass ich anstatt ArrayAdapter den SimpleCursorAdapter verwenden kann?
Hier mein Quelltext
Code
public class fahrzeuge extends ListActivity {
SQLiteDatabase myDB = null;
ArrayList<String> results = new ArrayList<String>();
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
myDB = this.openOrCreateDatabase(ensacom1.MY_DATABASE_NAME, MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT id, name, model FROM " + ensacom1.MY_DATABASE_TABLE + ";", null);
int kfzIDColumn = c.getColumnIndex("id");
int kfzNameColumn = c.getColumnIndex("name");
int kfzModelColumn = c.getColumnIndex("model");
startManagingCursor(c);
c.moveToFirst();
if (c != null) {
if (c.isFirst()) {
int i = 0;
do {
i++;
String kfzid = c.getString(kfzIDColumn);
String kfzname = c.getString(kfzNameColumn);
String kfzmodel = c.getString(kfzModelColumn);
results.add(kfzid + ": "+ kfzname + " - " + kfzmodel);
} while(c.moveToNext());
}
}
this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results));
}
Alles anzeigen