在list的配置xml的根节点添加属性android:descendantFocusability="blocksDescendants",还有就是在要添加事件的控件上加android:focusable="false"。
我们看看
android:descendantFocusabilityDefines the relationship between the ViewGroup and its descendants when looking for a View to take focus.
Must be one of the following constant values.
ConstantValueDescriptionbeforeDescendants0The ViewGroup will get focus before any of its descendants.afterDescendants1The ViewGroup will get focus only if none of its descendants want it.blocksDescendants2The ViewGroup will block its descendants from receiving focus最后一个是ViewGroup将阻止其后代接收焦点
所以 如果Listview中想不被屏蔽OnItemClickListener事件的话 那么久在item中的布局中 的最顶层布局加入这句话
想要阻止哪个widget 就在哪个widget设置focusable="false"
具体的实例看下面的
http://blog.chinaunix.net/space.php?uid=9935135&do=blog&id=181843
本文介绍如何解决ListView中Item点击事件被子View如Button抢夺焦点的问题,通过设置特定属性实现ListView ItemClick事件正常触发。
468

被折叠的 条评论
为什么被折叠?



