使用 MatrixCursor 时刷新 ListView 中特定行的最佳方法

发布于 2025-01-07 11:50:25 字数 439 浏览 7 评论 0原文

我有一个 ListView,其中包含来自 MatrixCursor 的自定义 CursorAdapter feed。 ListView 中的每一行都有一个异步加载的图像,当图像加载完成时,我想通知适配器重绘相关行。我已经对来自 ContentProvider 的数据执行了类似的操作,其中我调用 getContentResolver().notifyChange 来重绘特定行。对于 MatrixCursor,我可以调用 notifyDataSetChanged,但这并不是最佳选择,因为它会刷新每一行。

所以我的问题是,从临时源重绘 ListView 中的特定行的最佳方法是什么?有没有办法设置“临时”ContentUri,或者以某种方式请求适配器仅使特定行无效?

I have a ListView with a custom CursorAdapter feed from a MatrixCursor. Each row in the ListView has an image that is loaded asynchronously, and when the image loading completes, I would like to signal the adapter to redraw the row in question. I do something similar already with data from a ContentProvider where I call getContentResolver().notifyChange to redraw a specific row. For a MatrixCursor, I can call notifyDataSetChanged, but that's not optimal, as it refreshes every row.

So my question is, what's the best way to go about redrawing specific rows in a ListView from a temporary source? Is there a way to set up "temporary" ContentUris, or some way to request that the adapter only invalidate specific rows?

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

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

发布评论

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

评论(1

那小子欠揍 2025-01-14 11:50:25

我能够在具有任意 URI 的 MatrixCursor 上使用 setNotificationUri 实现相同的效果,然后使用 getContentResolver.notifyChange() 发出重绘信号。虽然这对我有用,但我很想知道这是否是请求重绘特定项目的建议方式。

I was able to achieve the same effect using setNotificationUri on MatrixCursor with an arbitrary URI, then using getContentResolver.notifyChange() to signal a redraw. While this works for me, I'd be curious to know whether this is an advised way of requesting redraw of specific items.

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