Dennis Winter
Dennis Winter

Reputation: 2037

Refreshing an ExpandableListView from within the adapter on Android

I'm having trouble on how to refresh an ExpandableListView from within one of its childViews.

The listView contains a list of files, and I want to offer a possibility to delete those files. But after a deletion is performed, the ExpandableListView needs to be refreshed. I implemented my own adapter which extends the BaseExpandableListAdapter. It seems there is no way to get my parent object from within the overwritten getChildView() method to send a notifyDataSetChanged(). :-s

I thought about sending an intent to my activity which contains information on the state of the groups (collapsed/expanded) and to refresh on receive, but even for this I would need the ExpandableListView object.

How can this be done?

Thanks in advance!

Be well
S.

Upvotes: 1

Views: 5476

Answers (1)

thaussma
thaussma

Reputation: 9886

You have to

  • remove the corresponding item from your adapter
  • and then call adapter.notifyDataSetChanged()

Then the ListView will reload the data.

Upvotes: 7

Related Questions