如何给MergeCursor排序?[英] How to sort MergeCursor?

本文是小编为大家收集整理的关于如何给MergeCursor排序?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

任务是将来自2个不同表格的数据组合在一起,并由一列排序. 似乎Mergecursor可能会有所帮助,但不知道如何分类项目.

我现在看到的唯一解决方案是手动转换为ArrayAdapter,或者偷偷摸摸地连接(尚不确定它的可能)

谢谢.

推荐答案

MergeCursor不提供排序.

我现在看到的唯一解决方案是手动转换为ArrayAdapter,或者偷偷摸摸地连接(尚不确定它的可能)

我不知道后者是什么.如果要坚持使用Cursor界面,则可以构建MatrixCursor.或者,您可以尝试创建自己的CursorWrapper,以维护排序顺序并重写所有与位置相关的呼叫.

本文地址:https://www.itbaoku.cn/post/102711.html

问题描述

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.

推荐答案

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.