Android problem summary: (1) June-1.1 ListView array out of bounds

Source: Internet
Author: User

W/dalvikvm( 5176): threadid=1: thread exiting with uncaught exception (group=0x40015568)E/zhe800_android( 5176): Invalid index 2, size is 0E/zhe800_android( 5176): java.lang.IndexOutOfBoundsException: Invalid index 2, size is 0E/zhe800_android( 5176): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)E/zhe800_android( 5176): at java.util.ArrayList.get(ArrayList.java:311)E/zhe800_android( 5176): at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:225)E/zhe800_android( 5176): at android.widget.AbsListView.obtainView(AbsListView.java:1424)E/zhe800_android( 5176): at android.widget.ListView.makeAndAddView(ListView.java:1755)E/zhe800_android( 5176): at android.widget.ListView.fillUp(ListView.java:704)E/zhe800_android( 5176): at android.widget.ListView.fillGap(ListView.java:650)E/zhe800_android( 5176): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3422)E/zhe800_android( 5176): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2920)E/zhe800_android( 5176): at android.os.Handler.handleCallback(Handler.java:587)E/zhe800_android( 5176): at android.os.Handler.dispatchMessage(Handler.java:92)E/zhe800_android( 5176): at android.os.Looper.loop(Looper.java:130)E/zhe800_android( 5176): at android.app.ActivityThread.main(ActivityThread.java:3703)E/zhe800_android( 5176): at java.lang.reflect.Method.invokeNative(Native Method)E/zhe800_android( 5176): at java.lang.reflect.Method.invoke(Method.java:507)E/zhe800_android( 5176): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)E/zhe800_android( 5176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)E/zhe800_android( 5176): at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime( 5176): FATAL EXCEPTION: mainE/AndroidRuntime( 5176): java.lang.IndexOutOfBoundsException: Invalid index 2, size is 0E/AndroidRuntime( 5176): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)E/AndroidRuntime( 5176): at java.util.ArrayList.get(ArrayList.java:311)E/AndroidRuntime( 5176): at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:225)E/AndroidRuntime( 5176): at android.widget.AbsListView.obtainView(AbsListView.java:1424)E/AndroidRuntime( 5176): at android.widget.ListView.makeAndAddView(ListView.java:1755)E/AndroidRuntime( 5176): at android.widget.ListView.fillUp(ListView.java:704)E/AndroidRuntime( 5176): at android.widget.ListView.fillGap(ListView.java:650)E/AndroidRuntime( 5176): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3422)E/AndroidRuntime( 5176): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2920)E/AndroidRuntime( 5176): at android.os.Handler.handleCallback(Handler.java:587)E/AndroidRuntime( 5176): at android.os.Handler.dispatchMessage(Handler.java:92)E/AndroidRuntime( 5176): at android.os.Looper.loop(Looper.java:130)E/AndroidRuntime( 5176): at android.app.ActivityThread.main(ActivityThread.java:3703)E/AndroidRuntime( 5176): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 5176): at java.lang.reflect.Method.invoke(Method.java:507)E/AndroidRuntime( 5176): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)E/AndroidRuntime( 5176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)E/AndroidRuntime( 5176): at dalvik.system.NativeStart.main(Native Method)W/ActivityManager(  197):   Force finishing activity com.tuan800.tao800/.activities.CategoryDealActivity


Cause:

The error log shows that the specific problem is not located.

Tracking the source code of ListView. It can be seen that the data source bound to the Adapter has an array out of bounds.

At this time, two or more threads may modify the data source at the same time. This problem occurs.


References:

Http://bbs.csdn.net/topics/390775554

Http://blog.csdn.net/tw19811220/article/details/9139595

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

Http://www.chengxuyuans.com/Android/63263.html

Http://hi.baidu.com/guoxiaoming/item/7b337449864f3fe11381dacd

Http://bbs.csdn.net/topics/390808917


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.