ScrollView nested listview in Android displays only one line of solution
Solution 1:
Removing the ScrollView control that contains the ListView control directly from the layout file leaves the ListView control, which is the simplest and quickest solution.
If you must include a ListView in ScrollView, refer to the
Solution 2:
Public void showlist() {listNewArraylist for(inti =0; I <8; i++) {hashmap<string, string> map =NewHashmap<string, string> (); Map.put ("Name","Zhang San"+ i); Map.put ("Phone","1333333333"+ i); Datahashmaps.add (map); } System.out.println (Datahashmaps.size ()); Simpleadapter adapter =NewSimpleadapter ( This, Datahashmaps, R.layout.item,NewString[] {"Name","Phone"},New int[] {r.id.name, r.id.phone}); ListView ListView = (ListView) Findviewbyid (R.id.list); Listview.setadapter (adapter);//Treatment solutions: intTotalheight =0;//If no data adapter is set, the ListView does not have subkeys and returns. for(intindex =0, Len = Adapter.getcount (); Index < Len; index++) {View ListViewItem = Adapter.getview (Index,NULL, ListView);//Calculate the width height of the child viewListviewitem.measure (0,0);//Calculates the height of all children andTotalheight + = Listviewitem.getmeasuredheight (); } viewgroup.layoutparams params = Listview.getlayoutparams ();//Listview.getdividerheight () Gets the height of the delimiter between children //Params.height Setting the ListView to fully display the required heightParams.height = Totalheight + (listview.getdividerheight () * (Adapter.getcount ()-1)); Listview.setlayoutparams (params); }
ScrollView nested listview in Android displays only one line of solution