Create cursor loader from two datasources?

你。 提交于 2019-12-25 09:24:23

问题


I have a method that queries a database table via a provider and returns a CursorLoader to be used to populate a UI via a CursorAdapter.
I need in one particular case only to add some extra data that are not part of the database result set.
Is there a way to somehow for that case add some extra "fake" rows with the data?
Like creating a cursor loader from two data sources?


回答1:


Yes. Use MatrixCursor to add some "fake" rows. Then merge the two cursors (CursorAdapter, MatrixCursor) using the MergeCursor class. MergeCursor will present the two Cursors as a single linear Cursor.



来源:https://stackoverflow.com/questions/39109521/create-cursor-loader-from-two-datasources

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