tags:

views:

37

answers:

1

I have a ListActivity working as expected. When a list item is clicked the app responds properly. I want to add a checkbox on the far right side of the screen, next to each list item. When I attempted to do that by updating the XML (see below) I lost the onListItemClick functionality. When I clicked on a list item nothing happened.


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TableLayout
        android:id="@+id/table1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="1">

        <TableRow>
            <TextView android:id="@+id/tvProduct" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:paddingLeft="10sp"
                android:paddingRight="10sp" />
        </TableRow>

    </TableLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView android:id="@+id/tvPrice" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="10sp"
            android:paddingRight="10sp"
            android:textColor="#606060" />

    </LinearLayout>

</LinearLayout>

I am trying to add the checkbox next to the tvProduct object.

Any help is appreciated.

A: 

When a ListView has focusable (clickable) children, it loses focusablitity itself. You can either have a checkbox (button, etc) by clickable inside of a ListView, or have the entire row be clickable.

If you are trying to allow the user to select multiple rows and show the selection state in a checkbox, you can use the choiceMode CHOICE_MODE_MULTIPLE.

Here is an example of it in use.

Mayra
Thank you. That is exactly what I want it to look like, but I don't think the functionality is what I'm looking for.The user will have 3 tabs, each resulting in a ListActivity. The first tab will consist of unchecked values, the 2nd is checked values, and the 3rd is all values. When a checkbox is selected I want the tool to move it to the proper tab (checked or unchecked).
alockrem