0 votes
in Education by (1.7m points)
I'm beeing bit confused here.

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.bugs_list_item, itemCursor,

            new String[] {db.KEY_ROWID, db.BUGS_DATE, db.BUGS_DESCRIPTION},

            new int[] {R.id.bug_id, R.id.bug_date, R.id.bug_description});

This basically shows me a ListView with date and description but no id (I just get blank space in place of id). _id field is primary key, it's an integer.

See how it looks on the img

XML file:

<?xml version="1.0" encoding="utf-8"?>

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/tableLayout1"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:stretchColumns="1"

    >

        <TableRow

        android:id="@+id/tableRow1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content">

            <TextView             

            android:id="@+id/bug_id"

            android:layout_width="5dip"

            android:layout_height="wrap_content"

            android:padding="3dip"                      

            >

            </TextView>

            <TextView            

            android:id="@+id/bug_date"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:padding="3dip"

            android:gravity="right"

            >

            </TextView>

            <TextView            

            android:id="@+id/bug_description"

            android:layout_width="180dip"

            android:layout_height="wrap_content"

            android:padding="3dip"

            android:gravity="right"

            >

            </TextView>

        </TableRow>

    </TableLayout>

create table query:

BUGS_CREATE = "CREATE TABLE bugs (_id INTEGER NOT NULL PRIMARY KEY, date DATE DEFAULT (DATETIME('NOW')) NOT NULL, description TEXT) ";

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.7m points)
It's very important that your "id-field" does have the name "_id", else it might not work.
...