Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get _id field from table and put it into ListView
    text
    copied!<p>I'm beeing bit confused here.</p> <pre><code> 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}); </code></pre> <p>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.</p> <p>See how it looks on the img</p> <p><img src="https://i.stack.imgur.com/GPEGC.jpg" alt="enter image description here"></p> <p>XML file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:id="@+id/bug_id" android:layout_width="5dip" android:layout_height="wrap_content" android:padding="3dip" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/bug_date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:gravity="right" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/bug_description" android:layout_width="180dip" android:layout_height="wrap_content" android:padding="3dip" android:gravity="right" &gt; &lt;/TextView&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p>create table query:</p> <pre><code>BUGS_CREATE = "CREATE TABLE bugs (_id INTEGER NOT NULL PRIMARY KEY, date DATE DEFAULT (DATETIME('NOW')) NOT NULL, description TEXT) "; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload