更新 MergeAdapter 的内容

发布于 2024-12-01 21:16:48 字数 577 浏览 0 评论 0原文

我有一个非常漂亮的 MergeAdapter,其中包含一堆自定义视图和一些自定义 ListAdapter。此 MergeAdapter 驱动一个 ListActivity,该 ListActivity 显示每 x 秒更新一次的内容。

目前,我只是创建一个新的 MergeAdapter,创建并添加所有自定义视图(其中包括一些 ImageView) - 并在我的活动中的 ListView 上调用 setAdapter。

大约 10 分钟的更新后,我耗尽了堆空间并崩溃了。

最终因为添加了新的 ImageView,并引发了以下异常:

Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

使用更简单的适配器(如 ArrayAdapter),我只需更新数据集,然后调用

notifyDataSetChanged()

适配器。

是否有类似/推荐的方法来“更新” MergeAdapter?或者我应该遍历潜在复杂的 MergeAdapter 的内容并更新单个视图?

I have a pretty nifty MergeAdapter that contains a bunch of custom views and some custom ListAdapters. This MergeAdapter drives a ListActivity that displays content that get's updated every x seconds.

Currently I just create a new MergeAdapter, create and add all of my custom views (and this includes a few ImageViews) - and call setAdapter on the ListView in my activity.

After about 10 minutes of updates I run out of heap space and crash.

Ultimately because a new ImageView is added, and the following exception is thrown:

Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

With simpler adapters (like ArrayAdapter), I would just update the data set, and call

notifyDataSetChanged()

on the adapter.

Is there a similar/recommended approach for "updating" a MergeAdapter? Or should I be walking the contents of a potentially complex MergeAdapter and updating individual Views?

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

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

发布评论

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

评论(1

原谅过去的我 2024-12-08 21:16:48

是否有类似/推荐的方法来“更新”MergeAdapter?

notifyDataSetChanged() 有效,据我所知。当前的 MergeAdapter 具有将其内部的 ListAdapters 的任何更改传递到 MergeAdapter 中已注册的更改兴趣的代码。这可能还没有经过足够的测试,所以如果您有一个示例应用程序来演示其他情况,请发布指向它的链接或将其发送给我(提及这个SO问题)。

Is there a similar/recommended approach for "updating" a MergeAdapter?

notifyDataSetChanged() works, AFAIK. The current MergeAdapter has the code to ripple any changes from ListAdapters inside it to whatever has registered interests in changes in the MergeAdapter. This probably has not been tested enough, so if you have a sample app that demonstrates otherwise, post a link to it or send it to me (mention this SO question).

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