I keep getting this IndexOutOfBoundsException, but I can't figure out what causes it. My list has an adapter with a list of objects, and the objects are deleted based on the timestamp. Deletion is performed inside the getView method. Once the item is deleted, I call notifyDataSetChanged ().
The full source code is available on github, and here is a link to the listview adapter code: https://github.com/kenneho/run-for-the-bus/blob/master/app/src/main/java/net/kenneho/runnow /adapters/TravelsAdapter.java
This is the beginning of the stacktrace that I get:
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164) at android.widget.ListView.dispatchDraw(ListView.java:3307) at android.view.View.draw(View.java:15213) <snip>
I see that often the position value in getView can reach six or seven.
Can anyone spot an error here? Any help would be appreciated.
Regards, Kenneth
EDIT 1: * Link to an activity code that uses: https://github.com/kenneho/run-for-the-bus/blob/master/app/src/main/java/net/kenneho/runnow/InfoActivity. java * I inserted the most appropriate part of logcat here: http://pastebin.com/5FtU4EaM
android indexoutofboundsexception listview
kenneho
source share