Android: removing items from a ListView / ArrayAdapter action

I have a list (of messages) and I want to give the user the opportunity to remove these items from the list. I expanded ArrayAdapterand handed him ArrayListmy messages and would like to simply remove the item from this list and then update ListViewinstead of reloading the entire list of sent messages. The problem is that if there is only one message, and I delete it with listAdapter.remove(messageObject), the adapter still calls getView()and then throws NullPointerExceptionseverywhere. I'm not sure the best way to do this.

+5
source share
1 answer

Apparently, the situation is slightly inferior if you do not override the getCount () function in your custom ArrayAdapter. I set it to the size of my ArrayList, and now everything works correctly.

+7
source

All Articles