您的位置:首页 > 其它

listview 中item 加入 其他触发点击事件的widtget 冲突

2015-08-07 15:38 351 查看
今天工作 遇到了 listview item中加入button 结果button能够触发点击事件 但是 item死活不触发 原来 button将item的事件给屏蔽了 需要在自己的视图文件中加入1个属性 仅仅一个属性就够了

<?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="match_parent"

android:background="@drawable/listview_bg"

android:descendantFocusability="blocksDescendants"

android:paddingTop="10dp"

android:paddingBottom="10dp" >

<Button

android:id="@+id/recent_job_putaway"

android:layout_width="45dp"

android:layout_height="25dp"

android:textSize="13sp"

android:background="@drawable/soldout"

android:textColor="@color/salary_status_green"

android:text="下架" />

<Button

android:id="@+id/recent_job_soldout"

android:layout_width="45dp"

android:layout_height="25dp"

android:layout_marginLeft="10dp"

android:background="@drawable/delete_jianzhi"

android:textColor="@color/salary_status_red"

android:textSize="13sp"

android:text="删除"/>

</RelativeLayout>

只要在item的布局文件中加入 android:descendantFocusability="blocksDescendants"这个属性 一切问题搞定 真是烦人啊 安卓的 事件传播机制
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: