ScrollViewでListViewをネストした場合の不完全なソリューション


ScrollViewにListViewをネストする場合、ListViewは1行以上しか表示できない.
検証され、listviewで簡単に有効です.setAdapter()の後にUtilityを呼び出す.settListViewHeightBasedOnChilren(listview)はOkayです.
public class Utility {
    public static void setListViewHeightBasedOnChildren(ListView listView) {
            // ListView Adapter
        ListAdapter listAdapter = listView.getAdapter(); 
        if (listAdapter == null) {
            // pre-condition
            return;
        }

        int totalHeight = 0;
        for (int i = 0, len = listAdapter.getCount(); i < len; i++) {   //listAdapter.getCount() 
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);  // View  
            totalHeight += listItem.getMeasuredHeight();  // 
        }

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        //listView.getDividerHeight() 
        //params.height ListView 
        listView.setLayoutParams(params);
    }

}