tjerkw / Android-SlideExpandableListView

A better ExpandableListView, with animated expandable views for each list item
Apache License 2.0
1.98k stars 741 forks source link

notifyDataSetChanged() for SlideExpandableListAdapter #68

Open smahs opened 10 years ago

smahs commented 10 years ago

For a dynamic listview, issuing

((SlideExpandableListAdapter)getListAdapter()).notifyDataSetChanged();

does not recreate the listview. Am I missing something?

mousewithjetpack commented 10 years ago

I had a similar problem when deleting an item. One of the buttons in the expanded child was a delete button that removes a Person object from my people ArrayList and is supposed to remove that entire row from the list. Here is what I did in onClick:

people.remove(position);
adapter = new PersonArrayAdapter(people);
list.setAdapter(adapter);
((ActionSlideExpandableListView) list).collapse();

At first, instead of lines 2 and 3 above, I was just calling:

((ArrayAdapter<String>) adapter).notifyDataSetChanged();

but this results in a bug where the delete button in the new row that moves up to fill that space has its text left-justified.

So essentially I'm recreating the adapter with the modified ArrayList, then re-setting the new adapter to the list.

If anyone has a better solution for this I would like to hear it too!

xarlotie commented 9 years ago

Have you found a solution for this one?