问题
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