Android ListView中Button事件 点击冲突问题的解决方案

今天遇到一个问题:在设置listview  自定义adapter的时候 ,点击item有点击效果,然后点击item布局文件中的某个button 的时候  也同时触发了listview的点击效果,

解决方案是:

1.在adapter布局文件中添加

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/common_strip_setting_middle"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal" >

</LinearLayout>

 

 

2.在ImageButton中 添加

android:focusable="false"
<ImageButton
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/calling_btn"
                android:contentDescription="@string/empty"
                android:focusable="false" />

 

posted @ 2015-09-10 11:28  索利达尔·群星之怒  阅读(598)  评论(0编辑  收藏  举报