9. solve the problem that the ListView height cannot be fully displayed when ScrollView and ListView coexist ., Scrollviewlistview
Problem:
When ScrollView and ListView coexist, the ListView displays only one row, and other rows cannot be displayed.
Solution:
Rewrite the ListView as follows to solve the problem.
/** Solve the problem that when ScorllView and ListView coexist, the ListView only displays one row but not all.
* @ Author Caiyuan Huang
* 2014-9-26
*/
Public class CustomListView extends ListView {
Public CustomListView (Context context ){
Super (context );
// TODO Auto-generated constructor stub
}
Public CustomListView (Context context, AttributeSet attrs ){
Super (context, attrs );
// TODO Auto-generated constructor stub
}
Public CustomListView (Context context, AttributeSet attrs, int defStyle ){
Super (context, attrs, defStyle );
// TODO Auto-generated constructor stub
}
@ Override
Protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec ){
// TODO Auto-generated method stub
Int expandSpec = MeasureSpec. makeMeasureSpec (Integer. MAX_VALUE> 2,
MeasureSpec. AT_MOST );
Super. onMeasure (widthMeasureSpec, expandSpec );
}
}
ScrollView nested listview for android
The listItem method can only be used to display static data, that is, the data is written to death.
To Display Dynamic Data, you must customize a ListView and write a class to inherit Linearlayout.
How to Implement the nested listview in scrollview
We recommend that you do it in a listview. Make sure that addHeaderView (view, null, false) and addFooterView are correct.