1
19sheriff93
Neues Mitglied
- 0
Hi leute!
Bin zurzeit an meiner ersten App, hab aber folgendes problem:
Ich habe Eine DB erstellt, eine Abfrage und möchte diese nun in einer Listview ausgeben, in den tutorials klappts wunderbar, nur bei mir nicht
allerdings weiß ich nicht worans liegt, vil könnt ihr mir weiterhelfen:
DataBaseHelper.java Abfrage:
db_listview.java übermittlung an Listview:
Probier schon ewig herum, hoffentlich kann mir jemand Helfen
Danke im Vorraus
Bin zurzeit an meiner ersten App, hab aber folgendes problem:
Ich habe Eine DB erstellt, eine Abfrage und möchte diese nun in einer Listview ausgeben, in den tutorials klappts wunderbar, nur bei mir nicht
allerdings weiß ich nicht worans liegt, vil könnt ihr mir weiterhelfen:
DataBaseHelper.java Abfrage:
Code:
public Cursor fetchAllNotes() {
return myDataBase.query(false, "twhk_inn_utf8", new String[] {"_id","innname"},"districtID = ?", new String [] { "6"}, null, null, null, null);
}
Code:
package at.android.twhk;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.widget.SimpleCursorAdapter;
public class db_listview extends ListActivity {
private int mNoteNumber = 1;
private DataBaseHelper mDbHelper;
public static final int INSERT_ID = Menu.FIRST;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bezirke);
mDbHelper = new DataBaseHelper(this);
mDbHelper.open();
fillData();
}
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = mDbHelper.fetchAllNotes();
startManagingCursor(c);
String[] from = new String[] { DataBaseHelper.KEY_TITLE };
int[] to = new int[] { R.id.text1 };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
}
Danke im Vorraus