Create cursor loader from two datasources?

2019-09-05 15:39发布

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条回答
Summer. ? 凉城
2楼-- · 2019-09-05 16:22

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.

查看更多
登录 后发表回答