【问题标题】:Sorting a MatrixCursor in Android在 Android 中对 MatrixCursor 进行排序
【发布时间】:2011-11-08 11:10:31
【问题描述】:

我有一个这样的MatrixCursor

final String[] matrix  = { "_id", "name", "price" };
MatrixCursor  data = new MatrixCursor(matrix);
data.addRow(new Object[] { i++, name, price });

我在那里有几行。我正在寻找一种方法来对我的MatrixCursor 进行排序:

  • 根据名字的字母顺序AND
  • 按价格从低到高。

【问题讨论】:

    标签: android sorting matrixcursor


    【解决方案1】:

    您必须先使用 ArrayList 左右手动对所有记录进行排序。然后您必须将它们添加到 MartixCursor。没有其他方式 AFAIK。

    【讨论】:

    • 但是每个id、name和price都是相互关联的。当我想按字母顺序对名称进行排序时,每个名称都有指定的价格。我必须把一排看成一个整体。管理此任务的最佳方式是什么?
    • 我不知道按名称排序但是是的,您可以对价格进行排序,将其连同其 ID 一起放入一个数组中。然后您可以将它们添加到 MartrixCursor 中。我不知道其他way.sorry!
    猜你喜欢
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 2013-07-15
    • 2016-07-08
    • 2014-02-18
    • 1970-01-01
    相关资源
    最近更新 更多