有没有办法从在另一个自定义适配器项目的自定义适配器的主要活动调用notifyDataSetChanged()? [英] Is there a way to call notifyDataSetChanged() from the main activity for a custom adapter of an item inside another custom adapter?

查看:224
本文介绍了有没有办法从在另一个自定义适配器项目的自定义适配器的主要活动调用notifyDataSetChanged()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图解决这个问题,但我无法弄清楚呢。在我的布局有它的自定义适配器列表视图。每个视图里面我有存储在一个名为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.

我的问题是,经过我得到我的活动的的onActivityResult。我需要一个notifyDataSetChanged()发送到我的画廊适配器。如果我做的:

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();

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

所有适配器内部的项目刷新,只是有自己的自定义适配器的人。

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

现在我想,也许我想也许有一种方法重写onNotifyDataSetChanged()或类似的东西从送我ListAdapter内的通知,一旦我通知吧。但我找不到这样的事情,有没有办法做到这一点?

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();

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

据最高审计机关:ListAdapter.ViewHolder没有外围实例在范围入店有没有一种方法,使之获得

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?

在此先感谢

推荐答案

我感到羞愧......看起来,我忘了续几个变量为它工作的权利...

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();

.notifyDataSetChanged();

您只需要做正确

这篇关于有没有办法从在另一个自定义适配器项目的自定义适配器的主要活动调用notifyDataSetChanged()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆