2

It's my first Andoid app. I can't implement a multiple choise in my ListView(i want a checkbox in every row in my listview). I'm using the notepadv3 tutorial. Can someone help me, i'm a newbie in 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 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"/>

2 Answers 2

1

You need to include the checkbox in the xml layout R.layout.notes_row. If you post your xml code we might be able to help you more.

Sign up to request clarification or add additional context in comments.

2 Comments

i can't implement the checkbox in notes_row xml
Ertan, if you found my answer helpful. Please accept it by clicking the checkmark next to my response.
0

This thread in SO shows you how to display a CheckBox and TextView in each row of ListView and how to bind them to the database: Android: Binding data from a database to a CheckBox in a ListView?

You might want to have a look.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.