有没有办法从主活动中调用另一个自定义适配器内项目的自定义适配器的notifyDataSetChanged()?
我一直在尝试解决这个问题,但我还没有弄清楚。在我的布局中有一个列表视图及其自定义适配器。在每个视图中,我都有许多对象存储在名为 ViewHolder 的静态类中。一个是带有另一个自定义适配器的画廊。
我的问题是,在我的 Activity 上获得 onActivityResult 后。我需要向我的图库适配器发送一个notifyDataSetChanged()。如果我这样做:
((BaseAdapter)list.getAdapter()).notifyDataSetChanged();
除了具有自己的自定义适配器的项目外,适配器内的所有项目都会刷新。
现在我想也许我想也许有一种方法可以覆盖 onNotifyDataSetChanged() 或类似的东西,一旦我通知它,就可以从我的 ListAdapter 中发送通知。但我找不到这样的东西,有什么办法吗?
我还注意到,如果我尝试这样做:
((BaseAdapter)ListAdapter.ViewHolder.this.gallery.getAdapter()).notifyDataSetChanged();
它说:“没有 ListAdapter.ViewHolder 的封闭实例在范围内可访问”有没有办法使其可访问?
或者另一种方式来完成我想做的事情?
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我感到羞愧...似乎我忘记更新一些变量以使其正常工作...
适配器内部的适配器就会更新。
所以结论是,如果您调用: .notifyDataSetChanged(); ,
你只需要做对
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