Is there a way to call notifyDataSetChanged() from

2019-03-04 07:43发布

问题:

I've being trying to solve this problem but I couldn't figure it out yet. In my layout have a listview with its custom adapter. Inside each view I have many objects stored in a static class called ViewHolder. One is a gallery with another custom adapter.

My problem is that after I get an onActivityResult on my Activity. I need to send a notifyDataSetChanged() to my gallery adapter. If I do:

((BaseAdapter)list.getAdapter()).notifyDataSetChanged();

All the items inside the adapter are refreshed except the ones that have their own custom adapter.

Now I thought maybe I thought maybe there is a way to override onNotifyDataSetChanged() or something like that to send the notification from within my ListAdapter once I notify it. But I couldn't find something like this, is there a way to do this?

I've also noticed that if I try to do:

((BaseAdapter)ListAdapter.ViewHolder.this.gallery.getAdapter()).notifyDataSetChanged();

It sais: "No enclosing instance of ListAdapter.ViewHolder is accesible in scope" Is there a way to make it accessible?

Or another way to accomplish what I'm trying to do?

Thanks in advance

回答1:

I feel ashamed... It seemed that I forgot to renew a few variables for it to work right...

So the conclusion is the adapter inside the adapter gets updated if you call:

.notifyDataSetChanged();

You just have to do it right