listfragment onlistitemclick 没有响应 没有调用

来源:互联网 发布:希捷硬盘数据恢复软件 编辑:程序博客网 时间:2024/03/29 15:54

先说说情况吧,写了一个要ListView的Fragment的类,所以extends ListFragment,自定义Adapter填充ListFragment中打ListView,然后在onListItemClick响应item单击事件,但是。。。最后点击了Item都没有反应,恨死了。。。

经过四个小时的纠结,才发现是自定义的Adapter中,有 Button按钮,这个按钮已经截获了ItemClick,所以传不到ListView,最简单打解决方法是:

在ListItem的布局文件中,如果有Button,Checkbox这种控件,取消它的focusable就可以了

android:focusable="false"


Add: 到后来这个方法也不起作用了,得用另外的方法,就是。。。。。。在xml的根标签里添加:

android:descendantFocusability=”blocksDescendants”




四个小时的纠结就这么浪费了

原创粉丝点击