title: Android Listview with spinner and a checkbox
body: <p>I am a newbie to android development. I am trying to create a List which has a spinner, a edit text and a check box. The data for spinner and check box come from data base. I have the following files.</p>
  
  <pre><code>NewTransac class which extends ListActivity {
  
  private PayDbAdapter mDbHelper;
  private  Spinner paySpinner;
  private CheckBox mCheckBox;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.new_transac_listview);
       mDbHelper = new PayDbAdapter(this);
       mDbHelper.open();
  
       populatedata();
  }
  
  private void populatedata() {
  
      paySpinner = (Spinner)findViewById(R.id.payerspinner);
      mCheckBox = (CheckBox)findViewById(R.id.paidforcheckboxname);
  
      Cursor mCursor = mDbHelper.fetchAllTransactionValue();
      startManagingCursor(mCursor);
  
      // Create an array to specify the fields we want to display in the list.
      String[] from = new String[]{PayDbAdapter.KEY_NAME};
  
      int[] to = new int[]{android.R.id.text1};
      int[] cbto = new int[]{R.id.paidforcheckboxname};
  
      // Now create a simple cursor adapter and set it to display
      SimpleCursorAdapter adapter =
          new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, mCursor, from, to );
  
      adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
      paySpinner.setAdapter(adapter);
  
      SimpleCursorAdapter cbAdapter =
          new SimpleCursorAdapter(this, R.layout.show_new_transac_data, mCursor, from, cbto );
      setListAdapter(cbAdapter);
  }
  </code></pre>
  
  <p>The list view xml
  </p>
  
  <pre><code>&lt;ListView android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:drawSelectorOnTop="false"
      android:textSize="14sp"
  /&gt;
  
  &lt;TextView android:id="@android:id/empty"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/no_friends"
      android:textSize="14sp"
  /&gt;
  
  &lt;Button android:id="@+id/confirmpay" 
      android:text="@string/confirm"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:gravity="center_vertical|center_horizontal" 
      android:layout_gravity="center_vertical|center_horizontal|center"&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p></p>
  
  <p>list view filled xml</p>
  
  <p></p>
  
  <pre><code>&lt;TextView
      style="?android:attr/listSeparatorTextViewStyle"
      android:text="@string/listSeparatorPay"
      android:layout_marginTop="5dip"
      android:layout_marginBottom="5dip"
  /&gt;
  
  &lt;Spinner android:id="@+id/payerspinner"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:drawSelectorOnTop="true"
      android:prompt="@string/selectpayer"
  /&gt;
  
  &lt;TextView android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:text="@string/paytext"
  /&gt;
  
  &lt;EditText android:id="@+id/payamount" 
      android:layout_width="match_parent"
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:inputType="text"
  /&gt;
  
  &lt;TextView
      style="?android:attr/listSeparatorTextViewStyle"
      android:text="@string/listSeparatorPayedFor"
      android:layout_marginTop="5dip"
      android:layout_marginBottom="5dip"
  /&gt;
  
  &lt;CheckBox android:id="@+id/paidforcheckboxname"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
  /&gt;
  
  &lt;EditText android:id="@+id/paidforamount"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="number"
  /&gt;
  </code></pre>
  
  <p></p>
  
  <p><code>Problem</code><br>
  I get multiple spinners, checkboxes and edittext based on the number of fields in the database. I see that we cannot set the adapter for the checkbox as i set for the spinner.
  I need to get only one spinner with one edit text and multiple checkboxes(total number of database rows).  please help!</p>