0

I want to create 3 level RecyclerView like tree view in kotlin. Is there any tutorial and suggestions please let me know.

I already tried so many times with ExpandableListView and 3 RecyclerView, but didn't find any proper solution.

ppreetikaa
  • 1,149
  • 2
  • 15
  • 22
  • you can use tree view for this try this https://stackoverflow.com/questions/3271772/android-treeview – Amit pandey Feb 07 '20 at 12:13
  • There are many open source solutions for that, but in general it's not good practice to use trees in Android apps. It would be better if you open new level as new list, like it goes in many file managers. Do you really need tree? – Ircover Feb 07 '20 at 13:59

2 Answers2

0

By a multi-level RecyclerView, do you mean a RecyclerView with paths to different lists that branch depending upon which item has been selected? If that's the case, I would honestly recommend using a single adapter to cycle through multiple lists depending upon user input.

If you have a root list containing two items, each of which opens up its own list with its own unique set of data, you can easily implement code that notifies the adapter of which item in the root list was selected. From there, the adapter can update and switch the view accordingly. This can be applied to series of lists ad nauseam if you so choose, though I can't say I would recommend this kind of method for incredibly complex webs of lists that interact with each other.

Like Ircover said in their comment, I don't think a tree is necessary in this situation either, if only because (1) as stated, it isn't really best practice to do so for the kind of application you're making, and (2) it may unnecessarily over-complicate whatever you're trying to achieve with these branching paths in the first place. If you're willing/able to provide more information about what you're trying to do here, that may help others help you more precisely than I can :)

Full disclosure here: the blog post linked above is not a direct match that will solve your problem - it pertains specifically to displaying different types of data sets (from data classes and what have you,) but employs code that shows how different sets of data can be switched between in a single RecyclerView. Even if it isn't a god-sent solution or is only halfway helpful in solving your problem, I think it can provide some useful information to you.

ADO
  • 35
  • 8
0

Maybe a slightly dated question but looking into the same concept and I located this page https://blog.usejournal.com/multi-level-expandable-recycler-view-e75cf1f4ac4b . They have made a single adapter class to take care of all the navigation and so far seems to be the least complicated example of an expandable RecyclerView, though not in kotlin.

Edward Aarma
  • 305
  • 2
  • 8