Android Listview mit Spinner und Checkbox

Ich bin ein Neuling in der Android-Entwicklung. Ich versuche eine Liste mit einem Drehfeld, einem Bearbeitungstext und einem Kontrollkästchen zu erstellen. Die Daten für Spinner und Kontrollkästchen stammen aus der Datenbank. Ich habe die folgenden Dateien.

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);
}

Die Listenansicht xml

<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"
/>

<TextView android:id="@android:id/empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/no_friends"
    android:textSize="14sp"
/>

<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">
</Button>

list view filled xml

<TextView
    style="?android:attr/listSeparatorTextViewStyle"
    android:text="@string/listSeparatorPay"
    android:layout_marginTop="5dip"
    android:layout_marginBottom="5dip"
/>

<Spinner android:id="@+id/payerspinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:drawSelectorOnTop="true"
    android:prompt="@string/selectpayer"
/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/paytext"
/>

<EditText android:id="@+id/payamount" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:inputType="text"
/>

<TextView
    style="?android:attr/listSeparatorTextViewStyle"
    android:text="@string/listSeparatorPayedFor"
    android:layout_marginTop="5dip"
    android:layout_marginBottom="5dip"
/>

<CheckBox android:id="@+id/paidforcheckboxname"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>

<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"
/>

Problem
Ich erhalte mehrere Spinner, Kontrollkästchen und Edittext basierend auf der Anzahl der Felder in der Datenbank. Ich sehe, dass wir den Adapter für das Kontrollkästchen nicht so einstellen können, wie ich es für den Spinner eingestellt habe. Ich brauche nur einen Drehknopf mit einem Bearbeitungstext und mehreren Kontrollkästchen (Gesamtzahl der Datenbankzeilen). bitte helft!

Antworten auf die Frage(4)

Ihre Antwort auf die Frage