I have a custom Listview using a ArrayAdapter of a Item class. I have the ability to change between choice modes of NONE,Single and Multi. This all works fine. What I am trying to implement now is a method to remove items from the list view (and adapter) with single or multiple selections. However I get IndexOutOFBounds Exceptions when doing either of the following; 1) remove last item in listview in SINGLE or MULTI choice mode (Note: anything before last item will remove ok if single item)2) in multi selection mode I can remove single selected items before last item but 2 or more selections result in index out of bounds errors again.

I added debug log to show position being removed and size of getCheckItemPositions() and my for loop counter (e.g. i) and finally the item title of the item being removed. If I comment out the actual "listadpter.remove(position)" line then the log output seems to indicator all is working fine So I am now suspecting the issue falls into my adapter class getView method. But my brain is exhausted and I am stuck. Below is my code.

MainActivity.class - removeItems method called from a button view object;

Log.d("drp", "Adapter Count is: " + Integer.toString(mMyListViewAdapter.getCount())); if (checkedItems != null) { for (int i = checkedItemsCount-1; i >= 0 ; i--) { // This tells us the item position we are looking at // -- final int position = checkedItems.keyAt(i); // This tells us the item status at the above position // -- final boolean isChecked = checkedItems.valueAt(i);

/** * This is my view holder for getView method so don't need to call * findViewById all the time which results in speed increase */static class ViewHolder {

public TextView txtTitle; public TextView txtDescription; public TextView txtSessionCount; public ImageView listThumbnailImage; public ImageView listStatusIndicatorImage; public InertCheckBox Checkbox;}

Again if I comment out the "mMyListViewAdapter.remove(item);" line in MainActivity not crashes and log seems to indicated its working as expected. Can anyone see my error that results in my Index Out Of Bounds Exception?