At Android.widget.abslistview$recyclebin.addscrapview (Abslistview.java:)

Source: Internet
Author: User

    • Error hints
    • Cause of error
    • Reference links

Error message:

At Android.widget.abslistview$recyclebin.addscrapview (abslistview.java:)
When I wrote several different item layouts to the ListView in Android, I encountered an array out-of-bounds error in the header, which I had encountered before, but this time I had a re-understanding of the cause of the error.

Cause of Error:

When writing multiple item entries to the ListView, we need to rewrite the getitemviewtype () and Getviewtypecoun () two methods in the adapter adapter, which we typically Getitemviewtype () makes a distinction between the specific item (the return value types of both methods are of type int ) so that the different layout layouts are loaded in GetView () , while the The Getviewtypecount () method defines the number of different item types that cause the error in the header to appear, which can be explained by using a word from StackOverflow : "The Item view type you was returning from Getitemviewtype () is >= getviewtypecount (). " The Chinese means that the value of getviewtypecount () must be greater than the value of getitemviewtype () , and conversely, the error in the header will appear, usually we are from 1 Starting with different item types, for example, for chestnuts, we set the item type of type 1 and type 2, and then return 2 in the Getviewtypecount () method, so that the value of Getviewtypecount () is Typ When E is 2, the return value is equal, so the data out-of-bounds error appears in the header, usually we set the type value to count from 0 to ensure that the type of the maximum value is not greater than the return value of the Getviewtypecount () method, Getitemviewtype () The comments in the source code also remind us that "integers must is in therange 0 to {@link #getViewTypeCount}-1".

Reference Links:

http://lmbj.net/blog/arrayindexoutofboundsexception/
Http://www.cnblogs.com/xitang/p/3197158.html

At Android.widget.abslistview$recyclebin.addscrapview (Abslistview.java:)

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.