How to sort MergeCursor?

2019-02-15 11:48发布

The task is to combine data from 2 different tables with similar columns, sorted by one column . Seems like MergeCursor might help, but have no idea how to sort items.

The only solutions I see now is converting manually to ArrayAdapter, or do sneaky JOINs (not sure yet its possible)

Thanks.

1条回答
倾城 Initia
2楼-- · 2019-02-15 12:52

MergeCursor does not offer sorting.

The only solutions I see now is converting manually to ArrayAdapter, or do sneaky JOINs (not sure yet its possible)

I have no idea what the latter is. If you want to stick with the Cursor interface, you can build yourself a MatrixCursor. Or, you can try to create your own CursorWrapper that maintains the sort order and rewrites all position-related calls.

查看更多
登录 后发表回答