SimpleCursorAdapter deprecated in API version 15?

我是研究僧i 提交于 2019-11-27 08:49:43

Only the constructor is deprecated, not the whole class.

SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) calls SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to, int flags) with flags set to FLAG_AUTO_REQUERY.

But FLAG_AUTO_REQUERY is deprecated because

[...] it results in Cursor queries being performed on the application's UI thread [...]

so also the constructor is deprecated.

The standard constructor is not deprecated but, obviously, you don't have to call it with flags = FLAG_AUTO_REQUERY!

Finally, if you are using SimpleCursorAdapter with a CursorLoader, as the documentation suggests, this flag is not needed and you can pass 0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!