在 Android 上从适配器内刷新 ExpandableListView

发布于 2024-11-19 01:07:49 字数 418 浏览 10 评论 0原文

我在如何从其子视图之一刷新 ExpandableListView 时遇到了麻烦。

listView 包含文件列表,我想提供删除这些文件的可能性。但是执行删除后,需要刷新ExpandableListView。 我实现了自己的适配器,它扩展了BaseExpandableListAdapter。似乎无法从覆盖的 getChildView() 方法中获取我的父对象来发送 notifyDataSetChanged() 。 :-s

我考虑过向我的活动发送一个意图,其中包含有关组状态(折叠/展开)的信息并在接收时刷新,但即使如此,我也需要 ExpandableListView 对象。

这怎么能做到呢?

提前致谢!

祝你一切顺利
S。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女中豪杰 2024-11-26 01:07:49

您必须

  • 从适配器中删除相应的项目
  • ,然后调用adapter.notifyDataSetChanged()

,然后ListView将重新加载数据。

You have to

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

Then the ListView will reload the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文