使用 MatrixCursor 时刷新 ListView 中特定行的最佳方法
我有一个 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" ContentUri
s, or some way to request that the adapter only invalidate specific rows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够在具有任意 URI 的
MatrixCursor
上使用setNotificationUri
实现相同的效果,然后使用getContentResolver.notifyChange()
发出重绘信号。虽然这对我有用,但我很想知道这是否是请求重绘特定项目的建议方式。I was able to achieve the same effect using
setNotificationUri
onMatrixCursor
with an arbitrary URI, then usinggetContentResolver.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.