您的位置:首页 > 其它

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: