【Android】 解决listview和BaseAdapter配合因加入button导致整个item点击失效
来源:互联网 发布:java和.net哪个好 编辑:程序博客网 时间:2024/06/07 09:18
刚刚在学习listview时遇到的问题,相信大家学习listview时都看过类似的文章,我看的是这个,android应用开发全程实录-你有多熟悉listview?,对我帮助很大。
按照上面的,我自己写了一遍,然后都正常,就是listview中有button的话,整个item无法点击了。
纠结了好久,也没明白,最后还是问了公司的大神,才解决了这个问题,
要改动两个地方,一个是修改继承BaseAdapter类中的getView()方法,另一个是修改item的xml。
先说第一个,把
convertView = mInflater.inflate(R.layout.item, null);
改成
convertView = mInflater.inflate(R.layout.item_listview, parent,false);
第二处,填空listview的item布局中加入两句话
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:descendantFocusability="blocksDescendants" android:focusable="false">
上面是我们公司大神的心得,今天我在看你有多熟悉listview 时,发现我漏了一点东西。原来,在这篇博文中已经有了item失效的解决方法,只怪我粗心,没看见。
0 0
- 【Android】 解决listview和BaseAdapter配合因加入button导致整个item点击失效
- Android ListView中加入Button导致ItemClick事件失效
- GridView, ListView的item中嵌入button或其他view导致item点击失效的研究
- 一般情况下ListView中的 item点击事件和 item 中的Button按钮点击事件 同时需要时,就会出现Button抢占了item的焦距问题,导致ListView中的item点击事件无效,解决
- Android ListView item 点击事件失效问题的解决
- Android学习之解决ListView中item点击事件和item中Button点击事件冲突问题
- ListView的item中有Button,ImageButton之类的控件导导致item的点击事件失效
- Android listview的item中button的点击事件 item和button 可同时点击
- ListView的item点击失效解决
- ListView的item点击失效解决
- ListView的item点击失效解决
- ListView item上面有Button导致item点击无效
- ListView 的item中有多个控件导致列表点击事件失效解决
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- Android中ListView点击和ListView的item里面的Button或ImageView不能同时生效问题的解决
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- android SharedPreferences 多进程间数据共享
- jquery 学习总结
- 重温《黑客帝国》的感觉
- 学习iOS、React Native、算法开发的建议
- LUT
- 【Android】 解决listview和BaseAdapter配合因加入button导致整个item点击失效
- 宏元编程
- [UVA]10340 All in All
- 详细介绍Ubuntu网络配置方法
- MongoDB 聚合管道(Aggregation Pipeline)
- 对数组操作扩展方法
- 让textview显示实时更新的系统时间
- 【SPOJ- HORRIBLE】Horrible Queries【线段树】
- IntentService介绍及使用