Error when removing last item from ListView in Android

view story

http://stackoverflow.com – I have a ListView with a onListItemListener, I have it so if you tap a ListView Item it removes it, but for some reason if I remove the last item form the list, the app crashes and gives me this error (java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3) Does anyone have any idea what that means? This is my code: @Override protected void onListItemClick(ListView l, View v, int pos, long id) { super.onListItemClick(l, v, pos, id); adapter.remove(adapter.getItem(pos)); adapter.notifyDataSetChanged(); } (HowTos)