best native component to use for separate listview in android

♀尐吖头ヾ 提交于 2020-02-05 07:24:24

问题


Hi I need to have a list view which is separated by date which native component i should use in android?can zou help me mazbe with some links, how to do it.I have an list activity coded, and working fine.thanks or maybe some dropdown box if is better i mean sthink like that:


回答1:


An ExpandableListView with custom group and child layout and disabled collapsing would be the simplest solution for you.

The list of groups would be the dates, the list of children would be the childLists (for each group a list).

But with a BaseExpandableListAdapter and a hierarchical data structure it would be even easier.
There you'd need a Day class with name (or date), and a list of Child instances, where Child has a title and a details member.

  • Child {title: String, details: String}
  • Day {date: Date, List<Child> children}



回答2:


You could use a normal ListView, you'd just have to put logic in your adapters getView() method that inflates a date View at the appropriate times.



来源:https://stackoverflow.com/questions/5995940/best-native-component-to-use-for-separate-listview-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!