Can anybody help me with the SimpleCursorAdapter. I have a database with two columns "names" and "age".
All names should be displayed like a list. But nothing happens. It is just empty. How can I display the names on the screen?
This is my Java:
Using java Syntax Highlighting
- private void fillData() {
- // Get all of the rows from the database and create the item list
- myTeaCursor = myDBHelper.callUpAllTeas();
- startManagingCursor(myTeaCursor);
- // Create an array to specify the fields we want to display in the list (only NAME)
- String[] from = new String[]{TeaDB.KEY_NAME};
- // and an array of the fields we want to bind those fields to (in this case just text1)
- int[] to = new int[]{R.id.list};
- ListAdapter test = new SimpleCursorAdapter(this, R.layout.main, myTeaCursor, from, to);
- setListAdapter(test);
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
This is my XML:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- android:id="@+id/background1"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <LinearLayout
- android:id="@+id/background2"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <TextView
- android:id="@+id/list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1">
- </TextView>
- <ListView
- android:id="@android:id/list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1">
- </ListView>
- </LinearLayout>
- </LinearLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
The method "callUpAllTeas" looks like this:


