Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Self-Destruction Maintaining Scroll Position in a ListView

Shaurya Kalsi
Shaurya Kalsi
1,018 Points

Message List Clearing Gives Problems

When I clear the message list, and re-add the items to the listView, there is a delay in the clearing and re-adding. This means when I exit a certain image and try to click another, the app crashes:

java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.sk.shauryakalsi.flick.InboxFragment$1.onItemClick(InboxFragment.java:56) at android.widget.AdapterView.performItemClick(AdapterView.java:300) at android.widget.AbsListView.performItemClick(AbsListView.java:1247) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3215) at android.widget.AbsListView$3.run(AbsListView.java:4009) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5696) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)