解决OnscrollListener中Listview.getChildAt()为null问题
2016-04-27 20:23
447 查看
原因是listview子view只有可视范围部分
参考
https://gist.github.com/AizazAZ/3880ea62131cdd2c631f
public View getViewByPosition(int pos, XListView listView) { try { final int firstListItemPosition = listView .getFirstVisiblePosition(); final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1; if (pos < firstListItemPosition || pos > lastListItemPosition) { //This may occure using Android Monkey, else will work otherwise return listView.getAdapter().getView(pos, null, listView); } else { final int childIndex = pos - firstListItemPosition; return listView.getChildAt(childIndex); } } catch (Exception e) { e.printStackTrace(); return null; } }
参考
https://gist.github.com/AizazAZ/3880ea62131cdd2c631f
相关文章推荐
- makefile中条件判断与函数
- bash快捷键
- [被喷了6年的帖子]PHP、CakePHP哪凉快哪呆着去
- CodeForces - 236A Boy or Girl (模拟)水
- 关于Bitmap的二次采样
- 设计模式(14)之桥接模式
- ES5中新增的Array方法详细说明
- Spark中组件Mllib的学习2之MovieLensALS学习(集群run-eaxmples运行)
- 学习软件工程的知名网站
- 【VR】如何用Gear VR打造虚拟现实
- sort函数的使用
- Shell 脚本知识回顾 (四) —— Shell 命令及Shell 相关语句
- 6.DNS公司PC访问外网的设置 + 主DNS服务器和辅助DNS服务器的配置
- 漫画城之引导页+主页
- centos7搭建vsftpd环境详解(亲测)
- oracle update select (更新查询的sql)
- Android ListView通用适配器升级支持多种布局
- python文件操作命令
- 关于Ajax异步分页的一点点总结
- 剑指offer(40):二叉树的深度