Android 如何在Listview的每一行中实现复选框

Android 如何在Listview的每一行中实现复选框,android,android-listview,Android,Android Listview,这是我的第一个Andoid应用程序。我无法在ListView中实现多选项(我希望在ListView的每一行中都有一个复选框)。 我正在使用notepadv3教程。 谁能帮帮我,我是java的新手 private void fillData() { ListView lView = (ListView) findViewById(android.R.id.list); // Get all of the notes from the database and create the

这是我的第一个Andoid应用程序。我无法在ListView中实现多选项(我希望在ListView的每一行中都有一个复选框)。 我正在使用notepadv3教程。 谁能帮帮我,我是java的新手

private void fillData() {
     ListView lView = (ListView) findViewById(android.R.id.list);
    // Get all of the notes from the database and create the item list
    //lView = (ListView) findViewById(R.id.liste);
    Cursor c = mDbHelper.fetchAllNotes();
    startManagingCursor(c);
    String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
    int[] to = new int[] { R.id.text1 };
    // Now create an array adapter and set it to display using our row
    SimpleCursorAdapter notes =
        new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
    setListAdapter(notes);



您需要在xml布局R.layout.notes\u行中包含该复选框。如果您发布xml代码,我们可能会为您提供更多帮助。

中的此线程向您展示了如何在
列表视图
的每一行中显示
复选框
文本视图
,以及如何将它们绑定到数据库:


您可能想看一看。

如果您觉得我的答案有帮助,我无法实现notes\u row xmlErtan中的复选框。请点击我的回复旁边的复选标记接受。
<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<CheckBox android:text=""
    android:id="@+id/list_checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="false"
    />

<TextView android:id="@id/android:empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/no_notes"/>