9. solve the problem that the ListView height cannot be fully displayed when ScrollView and ListView coexist ., Scrollviewlistview

Source: Internet
Author: User

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.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.