淘先锋技术网

首页 1 2 3 4 5 6 7

相信很多像我一样的初学者在用listview时会遇到类似:item中如果有button的时候 

这个item中button的点击事件与listview中item点击事件 的响应不能同时满足

稍微研究了一会 学习到一个解决方案:


1、在item的xml布局文件的 根布局标签中加入

android:descendantFocusability="blocksDescendants"


2、在button标签的属性中添加

android:focusable="false"(android:clickable="true"这句貌似可以不加


tip: Don't forget to add the click event of button and the item click event of listview!