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"这个属性 一切问题搞定 真是烦人啊 安卓的 事件传播机制
<?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"这个属性 一切问题搞定 真是烦人啊 安卓的 事件传播机制
相关文章推荐
- 关于application/x-www-form-urlencoded编码
- .net mvc
- 多维数组和指针操作
- Linux基础正则表达式字符汇整(characters)
- 抖动算法
- Java实现查找树(BST,AVL,BTree,Trie)
- Linux基础正则表达式字符汇整(characters)
- Linux 常用命令的使用
- 关于动态分布函数
- MyEclipse 10.7汉化教程
- Struts2中action访问路径配置
- 细小知识点之Maven
- 从文本txt导入大量数据到excel报错
- HTTP跨域调用-传入URL就直接返回回来数据
- tree型的json数据按照json的某个字段对子节点进行排序
- 连接Oracle时报错ORA-12541: TNS: 无监听程序
- MyBatis的几种批量操作
- Android EditText 修改提示字体的大小
- 页面重绘和回流以及优化
- Seek the Name, Seek the Fame