如何在CursorAdapter的情况下使用了更新的ListView?情况下、使用了、如何在、ListView

2023-09-05 03:10:51 作者:醉酒笑红尘

我问那的原因是因为重新查询()是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