Android TreeView Examples and Libraries.
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Oclemy
Android DraggableTreeView – Drag and Nest TreeNodes
This is an android draggabletreeview tutorial. This is a custom adapter view that can render items in a tree manner. The nodes in the tree can then be dragged and nested infinitely.
It’s quite easy to use, once we’ve added dragtreeview component in our xml layout, we then reference it inside our mainactivity. We then instantiate as many treenodes as we like.
We can nest the items by adding them as children to specific treenodes. Of course we can do this programmatically in code or at runtime.
Views are nestable even at runtime. This is an adapterview, so we have SimpleTreeViewAdapter class. We instantiate it passing in the context as well as our root treenode. We this set adapter to our draggabletreeview.
It’s that simple. We use a DraggableTreeView library by Jake Bonk. The library is hosted in jitpack.io. You can find more details about the library here.
Screenshot
Android DraggableTreeView Example
Common Questions this example explores
Tools Used
This example was written with the following tools:
Libaries Used
Let’s go.
1. Build.Gradle(Project)
Lets jump directly to the source code. Build.Gradle(Project)
2. Build.Gradle(App)
3. MainActivity.java
4. ActivityMain.xml
5. ContentMain.xml
How To Run
Conclusion.
This was a simple android draggabletreeview example. How to bind data using simpletreeadapter, add treenodes and nest them both programmatically and at runtime.
More Resources