Question

I have a list (of messages) and I want to give the user the ability to remove these items from the list. I have extended an ArrayAdapter and give it an ArrayList of my messages and would like to simply remove an item from that list and then refresh the ListView instead of reloading the entire list of sent messages. The problem is, if there's only one message and I remove it using listAdapter.remove(messageObject), the adapter is still calling getView() and then throwing NullPointerExceptions all over the place. I'm not sure what the best way is to go about this.

Was it helpful?

Solution

Apparently things go a little haywire if you don't override the getCount() function in your custom ArrayAdapter. I set it to the size of my ArrayList and now everything seems to be working correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top