android – 如何在可扩展列表中指定子项的排序顺序?

android – 如何在可扩展列表中指定子项的排序顺序?,第1张

概述我正在开发一个会议应用程序,我们希望会话首先按时间分组,然后按房间位置分组.我已经成功地在我的ExpandableListActivity中按一个或另一个排序,但是对主要和次要排序都没有成功. conference application that displays the sessions first grouped by time and then by room location http: 我正在开发一个会议应用程序,我们希望会话首先按时间分组,然后按房间位置分组.我已经成功地在我的ExpandableListActivity中按一个或另一个排序,但是对主要和次要排序都没有成功. @H_404_7@

@H_404_7@conference application that displays the sessions first grouped by time and then by room location http://coreylatislaw.com/wp-content/uploads/2012/03/sort-issue.png

@H_404_7@建立

@H_404_7@>自定义内容提供程序(扩展ContentProvIDer)
>自定义列表适配器(扩展Baseexpandablelistadapter)
>自定义列表活动(扩展ExpandableListActivity)

@H_404_7@询问

@H_404_7@

Cursor cursor = context.getContentResolver()                           .query(uri,ScheduleData.PROJECTION,null,ScheduleData.soRT_ORDER);
@H_404_7@排序

@H_404_7@

public static final String SORT_ORDER = TimeSlots.QUAliFIED_TIMESTART + " ASC"; // timeslots.timestart
@H_404_7@失败的主要&二级排序

@H_404_7@

public static final String SORT_ORDER = TimeSlots.QUAliFIED_TIMESTART + " ASC," + Locations.QUAliFIED_name + " ASC"; // timeslots.timestart ASC,locations.name ASC    public static final String SORT_ORDER = TimeSlots.QUAliFIED_TIMESTART + "," + Locations.QUAliFIED_name + " ASC";     // timeslots.timestart,locations.name ASC
@H_404_7@第二个条款似乎对排序没有影响.这是ExpandableListActivity的限制吗?我应该以不同方式指定多个排序顺序项吗

解决方法 事实证明,类中有一个比较器覆盖了ORDERBY子句中指定的排序顺序.当使用上面的ORDERBY子句而没有比较器时,我得到了所需的排序.你可以这样做,但我正在杀死额外的代码并选择ORDERBY子句. @H_404_7@

@H_404_7@比较器路径:

@H_404_7@

// Sort childrenCollections.sort(group.children,CHILD_COMParaTOR);// Specify sort by locationstatic final Comparator<Child> CHILD_COMParaTOR = new Comparator<Child>(){    @OverrIDe    public int compare (Child child1,Child child2)    {        return child1.location.tolowerCase().compareto(child2.location.tolowerCase());    }};
总结

以上是内存溢出为你收集整理的android – 如何在可扩展列表中指定子项的排序顺序?全部内容,希望文章能够帮你解决android – 如何在可扩展列表中指定子项的排序顺序?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1124469.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存