You can't have a focusable object inside a ListView and still set an
onItemClickListener, so you can't have a checkbox and an onItemClickListener
and have them both work out of the box. Change the xml for the CheckBox to

   <CheckBox
       android:id="@+id/checkBox"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentRight="true"
       android:button="@layout/checkbox_state"
       android:focusable="false">
   </CheckBox>

and your onItemClickListener will work again, but your checkbox won't.  You
might try setting up an onItemClickListener to toggle the checkbox, and set
what you had intended for the original onItemClickListener to an
onItemLongClickListener.  That way tapping it would toggle the checkbox and
holding it would activate whatever else you had planned to do.

On Mon, Jun 27, 2011 at 4:16 PM, Manish Garg <mannishga...@gmail.com> wrote:

> Hi All,
>
> I have a simple list view in my application. I am implementing its
> setOnItemClickListener but it is not getting called:
>
>        <ListView android:layout_width="fill_parent"
>                android:layout_height="wrap_content"
>                android:id="@+id/sender_added"
>                android:layout_weight="1"
>                android:cacheColorHint="#00000000"
>                android:dividerHeight="1dip"
>                android:listSelector="@drawable/tab_regular"
>                android:divider="@drawable/listview_seperator">
>        </ListView>
>
> I am inflating it with the following row:
> <?xml version="1.0" encoding="utf-8"?>
> <RelativeLayout
>         xmlns:android="http://schemas.android.com/apk/res/android";
>         android:layout_width="match_parent"
>         android:layout_height="wrap_content"
>         android:layout_gravity="center_vertical"
>         android:padding="10dip">
>    <ImageView
>        android:layout_width="wrap_content"
>        android:layout_height="wrap_content"
>        android:id="@+id/ImageView">
>    </ImageView>
>    <TextView
>        android:id="@+id/Name"
>        android:layout_width="wrap_content"
>        android:layout_height="wrap_content"
>        android:textColor="#000000"
>        android:textSize="12dip"
>        android:layout_toRightOf="@id/ImageView">
>    </TextView>
>    <CheckBox
>        android:id="@+id/checkBox"
>        android:layout_width="wrap_content"
>        android:layout_height="wrap_content"
>        android:layout_alignParentRight="true"
>        android:button="@layout/checkbox_state">
>    </CheckBox>
> </RelativeLayout>
>
> Regards,
> Manish Garg
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to