An issue in which the GetView method calls are greater than the number of data bars in the adapter Adapter of the Android listview

Source: Internet
Author: User

Situation Description:

Today in the writing of data display, using the ListView, in its adapter, found that the number of times the GetView method execution is the data item n times (my side of the display is 4 times times, this times the value does not know will change), this is obviously unscientific!

Check the data and find the layout problem of the ListView. I set the android:layout_height= "wrap_content" Height to wrap_content. While the Wrap_content value makes the ListView not take the actual height, he also depends on the calculation to determine, and each time the calculation should trigger the ListView rendering, so the number of GetView calls will be more than the normal situation compared to several times.

Workaround:

In general, it is recommended to always set the height of Listiview in the layout file to: fill_parent (or Match_parent), which is not only the number of calls to GetView, but also the efficiency of the layout.

An issue in which the GetView method calls are greater than the number of data bars in the adapter Adapter of the Android listview

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.