How To Make TreeView In Android (Expandable List View in Expandable List View)

Step1: Download

Step2: Paste "atv,values and" in your project.

Step3: Replace Package Name In all "atv" folder files.

Step4: Create your tree starting from root element.

TreeNode root = TreeNode.root();

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

(Add tree view to layout)

AndroidTreeView tView = new AndroidTreeView(getActivity(), root);

Step5: Custom View for nodes

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

 * Created by admin on 31-03-2016.
public class MyHolder extends TreeNode.BaseNodeViewHolder<MyHolder.IconTreeItem> {
    ImageView img;
    TextView tvValue;

    public MyHolder(Context context) {

    public View createNodeView(TreeNode node, IconTreeItem value) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        final View view = inflater.inflate(R.layout.child/*your layout here*/, null, false);
        img = (ImageView) view.findViewById(;
        tvValue = (TextView) view.findViewById(;
        return view;
 //for toggle image on click////
    public void toggle(boolean active) {
        img.setImageResource(active ? R.drawable.add_wishlist : R.drawable.inquire_now);

    public static class IconTreeItem {
        public int icon;
        public String text;

        public IconTreeItem(int icon, String text) {

            this.icon = icon;
            this.text = text;

Step6: Connect View Holder with node.

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

Step6: onClick Working
TreeNode.setClickListener(new TreeNodeClickListener() {
                public void onClick(TreeNode node, Object value) {
                    //Your Code Here//


(Other fuctions)

Share on Google Plus

About Mayank Sharma

Mayadi is a knowlage source. You can learn, explore and play many things in a proper way. Mayadi Provides Best, Perfect and Quality Information. subscribe our youtube channel to be updated and and don't forget to take a look on our blog within every week, because we are here to upgrade your knowladge. We love to see you again and again and again...
    Blogger Comment
    Facebook Comment


Post a comment