您的位置:首页 > 移动开发 > Android开发

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

2011-03-23 09:57 881 查看
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"
/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐