2

I am looking for ways to implement Accordion view in Android.

I have tried with having a child and parent view inside recyclerview adapter and based on user action expand the hidden content inside the recyclerview item. I have used a custom linear layout manager to measure the height of the list dynamically and set that as height.

Any help is accepted. Thanks in Advance.!

Kannan_SJD
  • 1,022
  • 2
  • 13
  • 32
  • It's called ExpandableListView – Tim Aug 22 '17 at 09:55
  • I do not want to use a ListView atleast. I used a recyclerview. But the problem was the design demands me to use nested recyclerview upto 3 levels which took so much time to load – Kannan_SJD Aug 22 '17 at 10:13

2 Answers2

1

Try this and you will find what you need.

enter image description here

Siamak
  • 1,689
  • 1
  • 17
  • 26
0

Android has a component called ExpandableListView - read more about it here

rashmi1412
  • 47
  • 1
  • 8
  • Can I use another list view inside the ExpandableListView – Kannan_SJD Aug 22 '17 at 10:14
  • I didn't quite get your question. The ExpandableListView has a list of groups, clicking on a group will expand it to show it's children. It lets you set click listeners on the group as well as the child views. So if you're referring to the child views under a particular group as a list view, then yes, it is possible – rashmi1412 Aug 22 '17 at 10:20
  • Maybe this tutorial will help - https://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/ – rashmi1412 Aug 22 '17 at 10:20
  • I have tried this intially when I started with this. As per this google i/o I have used recyclerview. Refer: https://youtu.be/EjTJIDKT72M?t=5m50s – Kannan_SJD Aug 22 '17 at 10:29
  • also this https://stackoverflow.com/questions/27203817/recyclerview-expand-collapse-items – Kannan_SJD Aug 22 '17 at 10:29
  • 1
    It depends on your use case then. If you just have static options that will expand on clicking the item, the handling is easier to do. If it is a list, you might have to do a little more handling, so it's better to use the ExpandableListView. You can manage recycling of views manually by creating a viewholder and setting it as a tag on each view. If a view has a tag, simply reset the values on the fields, if it doesn't, create a new one. – rashmi1412 Aug 22 '17 at 10:42