Put another listview in one ListView, or put another listview in each ListItem of a ListView. found that the small ListView will show incomplete, its height is always a problem, by default, Android is forbidden to put another scrollview in the ScrollView, its height is not calculated.
After the experiment found that can solve the problem, the idea is to set the adapter of the ListView, according to the ListView sub-project to recalculate the height of the ListView, and then set the height again as layoutparams to the ListView, So it is the right height, the following is the source:
[HTML]View PlainCopyPrint?
- public class utility {
- public static void Setlistviewheightbasedonchildren (Listview listview) {
- listadapter listadapter  =  listview .getadapter ();
- if (listadapter == null) {
- Pre-condition
- Return
- }
- int totalheight = 0;
- for (intI = 0; I< Listadapter.getcount (); i++) {
- view < span class= "attribute" style= "margin:0px; padding:0px; Border:none; color:red; Background-color:inherit ">listitem &NBSP;=&NBSP; listadapter .getview (i, null, ListView);
- Listitem.measure (0, 0);
- Totalheight + = Listitem.getmeasuredheight ();
- }
- &NBSP;&NBSP;
- viewgroup.layoutparams params &NBSP;=&NBSP; listview .getlayoutparams ();
- params.height &NBSP;=&NBSP; totalheight + ( Listview.getdividerheight () * (Listadapter.getcount () - 1))
- Listview.setlayoutparams (params);
- }
- }
This static method is called after the adapter of the ListView is set so that the ListView is displayed correctly in the ListItem of its parent listview. Note, however, that each item of the child ListView must be linearlayout, not the other, because other layout (such as relativelayout) does not rewrite onmeasure (), so it will be in the Onmeasure () Throws an exception.
Another problem with nesting a ListView (or ScrollView) in ScrollView is that the child ScrollView cannot slide (if it is not shown), because the sliding event is eaten by the parent scrollview. If you want to let the sub-ScrollView can also slide, can only force interception of sliding events, there are cows in the forum sent code to say yes. Although I have not tried it myself, I think it is feasible.
While the technical challenges of ScrollView can be compromised in ScrollView, this design is a very poor user experience because it is not easy for users to see and manipulate the content in sub-scrollview. For example, a good design is that each item of the parent ListView only displays a general description, and then clicking on its item will go to another page to describe and display the item in detail.
Reference: Http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing
Nested ListView in ScrollView