I keep getting this IndexOutOfBoundsException, but can't seem to figure out what's causing it. My listview has an adapter with a list of objects, and the objects are removed based on a timestamp. The removal is done inside the getView method. Once an item is removed, I call notifyDataSetChanged().
The full source code is available on github, and here's 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 I keep getting:
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 within getView can get as high as six or seven.
Can anyone here spot the bug? Any help will be appreciated.
Regards, Kenneth
EDIT 1: * Link to the activity code that uses the : https://github.com/kenneho/run-for-the-bus/blob/master/app/src/main/java/net/kenneho/runnow/InfoActivity.java * I've pasted the most relevant logcat part here: http://pastebin.com/5FtU4EaM