Android solves the problem of white space in ListView when ListView uses multiple la S and uses convertView for caching.

Source: Internet
Author: User

Android solves the problem of white space in ListView when ListView uses multiple la S and uses convertView for caching.

When using ListView, using convertView In the Adapter will improve the performance of ListView by 100%? But today we found that while loading different views at the same time in the listView, there will be a blank space at the bottom of the ListView. It may happen that this may be caused by loading several different views, the system cannot accurately calculate the total height of the ListView because their heights are different and their quantities are different.

Two callback functions are provided in BaseAdapter to specify the layout and the layout corresponding to position.

@ Overridepublic int getViewTypeCount () {return 2 ;}@ Overridepublic int getItemViewType (int position) {if (getSectionForPosition (position) = 0) {return TYPE_1 ;} else {return TYPE_2 ;}}

Simply rewrite it to solve the problem.

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.