Be Smart

FANTAISIE

SmartPhone - iPhone, iPad, Android

导航

[Android 問題] How to Add a Button in ListView, and Make the Event of onClick and onItemClick Coexist?

If you add a Button on the view of each item in ListView,

the touch event is catched and reacted by the button instead of the ListView even outside the area of the Button.

The item can not be selected and switched.

It's a simplest solution that you can set the attribute android:focusable to be false to fix it as showed below:

<Button
     android:id="@+id/contact_list_item_hd_button"
  android:layout_width="30px"
     android:layout_height="30px"
     android:layout_gravity="center_vertical"
     android:layout_marginRight="10px"
     android:background="@drawable/contactlist_hd_button"
     android:textSize="8sp"
     android:focusable="false"
     android:visibility="invisible"
     />

posted on 2011-03-23 09:57  FANTAISIE  阅读(2225)  评论(0编辑  收藏  举报