views:

20

answers:

1

Hello I've already read quite a bit about the CheckBox/ListView problems in Android. So I've tried a number of issues.

To start my layout for a row looks like this.

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <CheckBox 
            android:id="@+id/check" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:focusable="false"
            android:focusableInTouchMode="false" 
            android:text="" /> 
   </LinearLayout>

So then I tried adding this to my ListActivity

 ListView listview = getListView();
 listview.setItemsCanFocus(false);

And then attempted to run it with a breakpoint on onListItemClick, still no hit (running debugging of course).

This is my onListItemClick in case you want to see.

@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {

        // let's find the checkbox we're on.
        CheckBox targetCheckBox = (CheckBox) l.findViewById(R.id.check);

        // ok update the database with the new data. 
        mDbHelper.updateNote(id, !targetCheckBox.isChecked());

        // update the list now.
        showList();

    }

If I then change the Checkbox to CheckTextView, it does work, however I've never done that before, and I'd rather figure out exactly what's wrong here when other people have solved this. Any Thoughts?

A: 

Apparently I was missing

"android:clickable="false""

under the Checkbox in addition to

"android:focusable="false""

Adding the both lines makes the onListItemClick fire correctly.

Kinglink