title: Android: Binding data from a database to a CheckBox in a ListView?
body: <p>I'm trying to bind data from my <code>SQLiteDatabase</code> to a <code>ListView</code>. I'm currently using a <code>SimpleCursorAdapter</code> to fill in my <code>ListView</code>. Unfortunately this doesn't seem to work with setting a CheckBox's checked attribute.</p>
  
  <p>This is how I do it now; instead of changing the CheckBox's checked status the adapter is filling in the value to the text argument, so the value is displayed right of the CheckBox as text.</p>
  
  <p>Java:</p>
  
  <pre><code>setListAdapter( new SimpleCursorAdapter( this,
        R.layout.mylist,
        data,
        new String[] { Datenbank.DB_STATE, Datenbank.DB_NAME },
        new int[] { R.id.list_checkbox, R.id.list_text }
      ) );
  </code></pre>
  
  <p>mylist.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout android:id="@+id/LinearLayout01"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android"
  &gt;
  
  &lt;CheckBox android:text=""
      android:id="@+id/list_checkbox"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:checked="false"
      &gt;&lt;/CheckBox&gt;
  
  &lt;TextView android:text=""
      android:id="@+id/list_text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      &gt;&lt;/TextView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Edit: The field in the database is of course of type boolean and I've also tried to assign an id to the checked field to fill the value in.</p>