ListView 悬停 + 如何在每个Adapter获取没个View
2016-06-12 22:38
387 查看
转载 :http://www.eoeandroid.com/thread-558736-2-1.html
ListAdapter listAdapter = listView.getAdapter();
if(listAdapter==null){
return;
}
int totalHeight = 0;
for(int i=0; len=listAdapter.getCount();i<len;i++){
View listItem = listAdapter.getView(i,null,listView); 获取每个View
listItem.measure(0,0); // 计算子项View 的宽高
totalHeight += listItem.getMeasureHeight(); // 统计所有子项的总高度
}
ViewGroup.LayoutParams parmas = listView.getLayoutParams();
parmas .height = totalHeight+(listView.getDividerHeight() * (listAdapter.getCound()-1));
listView.setLayoutParams(params);
ListAdapter listAdapter = listView.getAdapter();
if(listAdapter==null){
return;
}
int totalHeight = 0;
for(int i=0; len=listAdapter.getCount();i<len;i++){
View listItem = listAdapter.getView(i,null,listView); 获取每个View
listItem.measure(0,0); // 计算子项View 的宽高
totalHeight += listItem.getMeasureHeight(); // 统计所有子项的总高度
}
ViewGroup.LayoutParams parmas = listView.getLayoutParams();
parmas .height = totalHeight+(listView.getDividerHeight() * (listAdapter.getCound()-1));
listView.setLayoutParams(params);
相关文章推荐
- 如何解决访问Oracle时报错:“The Network Adapter could not establish the connection”?
- AR(增强现实) unity+vuforia 基础教程(2)!
- js 数组排序和算法排序
- HDU 2715 Herd Sums
- android微信支付
- MyEclipse快捷键大全
- 【GOF23设计模式】_享元模式_享元池_内部状态_外部状态_线程池_连接池JAVA242
- 算法学习与代码实现6——快速排序
- 如何解决启动PL/SQL连接orcale数据库时的“Initialization error”错误?
- Q25:二叉树中和为某一值的路径
- 在类树莓派的ARM开发板上组建大数据集群
- Linux之查看CPU信息
- SVN在团队项目中的使用技巧:[2]Tag操作
- 用webdriver+phantomjs实现无浏览器的自动化过程
- 132. Palindrome Partitioning II
- Leetcode刷题系列(二)Binary Search
- android 左右滑动实现切换背景
- 一些总结(二)
- SDUT 3571 Password 暴力搜索
- linux笔记二-----目录及文件命令