0

I would like to create a layout that would basically look like the image below.

Items are dynamic so a flavor of ListView ou ExpandableListView seems like a way to go but I'm curious to see if anyone would know of an existing component or a way of implementing it.

I don't care about collapsing the groups.

Thanks!

My example

ddx001
  • 2,575
  • 1
  • 17
  • 13

1 Answers1

0

If you don't care about collapsing groups (i.e. all children are displayed, always) you can get away using just a listview (or recycleview).

This means you can store your data simply as a list (instead of a list of lists), since all your items are defined simply as their position in the list (instead of a pair of indexes: e.g. group/child).

To do this, you would override the ListView getViewType and getViewTypeCount methods. I'd direct you to an existing post on how to implement those methods if you don't already know: Android ListView with different layouts for each row

Community
  • 1
  • 1
NameSpace
  • 10,009
  • 3
  • 39
  • 40
  • I've considered using that technique but it doesn't allow me to "embed" the sub items (to have them appear inside the parent's box). So far, my best guess is to use a RecyclerView for groups with a HorizontalView inside of it and to add the items programmatically... – ddx001 Jul 09 '15 at 11:01
  • Yes, to achieve the embed effect a recycleView inflating ViewGroups (corresponding to "group 1,2.3...", which you can extend to support dynamically adding children should work. – NameSpace Jul 09 '15 at 12:13