Android ListView Load encountered problems

Source: Internet
Author: User

http://blog.csdn.net/l_serein/article/details/7706338

Reproduced:

Describe the scene:

There are several categories on the menu bar, click on each category, and the ListView below shows the corresponding content according to the classification.

--------------------------

1. An exception occurred when switching categories. The description is as follows:

E/androidruntime (8131): Java.lang.IndexOutOfBoundsException:Invalid index One, size is 0

E/androidruntime (8131): at Java.util.ArrayList.throwIndexOutOfBoundsException (arraylist.java:257)

E/androidruntime (8131): at android.widget.HeaderViewListAdapter.isEnabled (headerviewlistadapter.java:164)

The probable cause is this:

When I switch the classification, the ListView must first clear, then the ListView again scrolls the time to write down the next time the index. When you load it, there is a indexoutofboundsexception. So, when I switch categories, I add

Mannouncementlv.setadapter (Mbulletinadapter);

Plus this is OK, do not report boundary overflow error ...

Reprint End

I have the same problem with this great God, which is solved by the way of the great God.

This is actually quite the same as refreshing the function, or you can use the Listviewadapter.notifydatasetchanged () method to solve this problem, both when the value of the ListView changes, you need to call this method to refresh

Android ListView Load encountered problems

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.