一键解决ScrollView嵌套ListView仅仅显示一行的问题

/**
* 解决ScrollView嵌套ListView仅仅显示一行的问题
*
* @param listView
*/ private void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); }
上一篇:Navicat Premium 12.1.12.0破解版激活


下一篇:基于visual Studio2013解决C语言竞赛题之0415特殊对数