AndroidTreeView

Tree View implementation for android

License

License

GroupId

GroupId

com.github.bmelnychuk
ArtifactId

ArtifactId

atv
Last Version

Last Version

1.2.9
Release Date

Release Date

Type

Type

aar
Description

Description

AndroidTreeView
Tree View implementation for android
Project URL

Project URL

https://github.com/bmelnychuk/AndroidTreeView
Source Code Management

Source Code Management

https://github.com/bmelnychuk/AndroidTreeView

Download atv

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.bmelnychuk/atv/ -->
<dependency>
    <groupId>com.github.bmelnychuk</groupId>
    <artifactId>atv</artifactId>
    <version>1.2.9</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.bmelnychuk/atv/
implementation 'com.github.bmelnychuk:atv:1.2.9'
// https://jarcasting.com/artifacts/com.github.bmelnychuk/atv/
implementation ("com.github.bmelnychuk:atv:1.2.9")
'com.github.bmelnychuk:atv:aar:1.2.9'
<dependency org="com.github.bmelnychuk" name="atv" rev="1.2.9">
  <artifact name="atv" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.bmelnychuk', module='atv', version='1.2.9')
)
libraryDependencies += "com.github.bmelnychuk" % "atv" % "1.2.9"
[com.github.bmelnychuk/atv "1.2.9"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 21.0.3

Project Modules

There are no modules declared in this project.

AndroidTreeView

Recent changes

2D scrolling mode added, keep in mind this comes with few limitations: you won't be able not place views on right side like alignParentRight. Everything should be align left. Is not enabled by default

Description

Tree view implementation for android

Android Arsenal

Demo

AndroidTreeView Demo on Google Play Store

Features

    1. N - level expandable/collapsable tree
    1. Custom values, views, styles for nodes
    1. Save state after rotation
    1. Selection mode for nodes
    1. Dynamic add/remove node

Known Limitations

  • For Android 4.0 (+/- nearest version) if you have too deep view hierarchy and with tree its easily possible, your app may crash


Integration

1) Add library as a dependency to your project

compile 'com.github.bmelnychuk:atv:1.2.+'

2) Create your tree starting from root element. TreeNode.root() element will not be displayed so it doesn't require anything to be set.

TreeNode root = TreeNode.root();

Create and add your nodes (use your custom object as constructor param)

 TreeNode parent = new TreeNode("MyParentNode");
 TreeNode child0 = new TreeNode("ChildNode0");
 TreeNode child1 = new TreeNode("ChildNode1");
 parent.addChildren(child0, child1);
 root.addChild(parent);

3) Add tree view to layout

 AndroidTreeView tView = new AndroidTreeView(getActivity(), root);
 containerView.addView(tView.getView());

The simplest but not styled tree is ready. Now you can see parent node as root of your tree

4) Custom view for nodes

Extend TreeNode.BaseNodeViewHolder and overwrite createNodeView method to prepare custom view for node:

public class MyHolder extends TreeNode.BaseNodeViewHolder<IconTreeItem> {
    ...
    @Override
    public View createNodeView(TreeNode node, IconTreeItem value) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        final View view = inflater.inflate(R.layout.layout_profile_node, null, false);
        TextView tvValue = (TextView) view.findViewById(R.id.node_value);
        tvValue.setText(value.text);
        
        return view;
    }
    ...
    public static class IconTreeItem {
        public int icon;
        public String text;
    }
}

5) Connect view holder with node

  IconTreeItem nodeItem = new IconTreeItem();
  TreeNode child1 = new TreeNode(nodeItem).setViewHolder(new MyHolder(mContext));

6) Consider using

TreeNode.setClickListener(TreeNodeClickListener listener);
AndroidTreeView.setDefaultViewHolder
AndroidTreeView.setDefaultNodeClickListener
...

For more details use sample application as example

Let me know if i missed something, appreciate your support, thanks!

Projects using this library

Blue Dot : World Chat

Versions

Version
1.2.9
1.2.8
1.2.7
1.2.6
1.2.4
1.2.2
1.2.0
1.1.0