Android resolves an issue in which the ListView has a blank under the ListView when using Convertview for caching while working with multiple layouts

Source: Internet
Author: User

When using the ListView, using Convertview inside the adapter will improve the performance of the ListView and increase the 100%? But today found that the ListView loading different view at the same time will lead to the bottom of the ListView a blank, it may happen that the cause of this may be loaded with a few different view, and their height is different, the number is different, The system cannot accurately calculate the total height of the listview.

In Baseadapter, two callback functions are provided to specify how many layouts are available, specifying which layout the position corresponds to.

@Overridepublic int Getviewtypecount () {return 2;} @Overridepublic int Getitemviewtype (int position) {if (getsectionforposition (position) ==0) {return type_1;} else {return type_2;}}

A simple rewrite will solve the problem.

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.