This method is called after the ListView is initialized Setadapter
/** * recalculates the height of the ListView, resolves ScrollView and ListView Two view have scrolling effect, conflicts when nested use problem * @param Listview */public void setlistviewheight (Listview listview) { // Get the adapter listadapter listadapter = for the ListView Listview.getadapter (); if (listadapter == null) { return; } int totalHeight = 0; for (Int i = 0, len = listadapter.getcount (); i < len; i++) { // listAdapter.getCount () returns the number of data items View Listitem = listadapter.getview (i,&Nbsp;null, listview); listitem.measure (0, 0); // Calculate the height of the child view Totalheight += listitem.getmeasuredheight (); // statistics total height of all children } Viewgroup.layoutparams params = listview.getlayoutparams (); params.height = totalHeight + (Listview.getdividerheight () * (Listadapter.getcoun t () - 1)); listview.setlayoutparams (params); }
ScrollView nested listview with LinearLayout Wrap, if there are other controls also to be wrapped up with linearlayout
This means that multiple linearlayout can be nested under ScrollView and can be slid
In addition, in the quoted R.layout.item must be used linearlayout can not use a similar relativelayout method, because the method will not be re-measure.
This article is from the "climb over the mountains to see the Sea" blog, please be sure to keep this source http://670176656.blog.51cto.com/4500575/1762065
ScrollView nested listview causes a slide show to not complete the problem