如何在CursorAdapter的情况下使用了更新的ListView? [英] How to update ListView in case of CursorAdapter usage?

查看:217
本文介绍了如何在CursorAdapter的情况下使用了更新的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问那的原因是因为重新查询()是pcated德$ P $。什么是现在刷新最好的办法你的的ListView

The reason I'm asking that is because requery() is deprecated. What is the best way now to refresh your ListView?

推荐答案

重新查询()更新一个光标,不是的CursorAdapter 。正如你所说,它已经去precated,其更换为:

requery() updates a Cursor, not a CursorAdapter. As you say, it has been deprecated, and its replacement is:

oldCursor = myCursorAdapter.swapCursor(newCursor); // hands you back oldCursor

myCursorAdapter.changeCursor(newCursor); // automatically closes old Cursor

myCursorAdapter.notifyDataSetChanged()通知的ListView ,该数据集已经变了,它应该自动刷新

myCursorAdapter.notifyDataSetChanged() notifies the ListView that the data set has changed, and it should refresh itself

这篇关于如何在CursorAdapter的情况下使用了更新的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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