如何排序MergeCursor?MergeCursor

2023-09-06 06:52:24 作者:你若安好那还得了

的任务是将数据从具有类似的列2个不同的表,排序由一列结合。 好像MergeCursor可能有帮助,但不知道如何排序的项目。

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.

我现在看到的是手动转换为ArrayAdapter,还是偷偷摸摸加入唯一的解决方案(目前还不能确定其可能的)

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

感谢。

推荐答案

MergeCursor 不提供排序。

我现在看到的是手动转换为ArrayAdapter,还是偷偷摸摸加入唯一的解决方案(目前还不能确定其可能的)

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

我不知道后面是什么。如果你想坚持使用光标的界面,你可以建立自己一个 MatrixCursor 。或者,你可以尝试创建自己的 CursorWrapper 维持排序顺序,并把所有的位置相关的调用。

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.