Skip to content

How to collapse other node expect current node clicked #156

Open

Description

@vinhgroup

i used this liblary. everything ok. but how to How to collapse other node expect current node clicked.

thanks in advance

Activity

  1. changed the title [-]How to collapse other not expect current node clicked[/-] [+]How to collapse other node expect current node clicked[/+] on Jun 19, 2018
  2. brunopizzo commented on Jun 15, 2019

    @brunopizzo

    I found a solution

    1. you create a class like that

    public class UtilityHolder {

    public static void collapseOthers(TreeNode mNode, AndroidTreeView treeView){
        if(mNode.isExpanded()) {
            TreeNode parent = mNode.getParent();
            for (TreeNode node: parent.getChildren()) {
                if(node != mNode){
                    treeView.collapseNode(node);
                    collapseChildern(node,treeView);
                }
    
            }
        }
    }
    
    private static void collapseChildern(TreeNode mNode, AndroidTreeView treeView) {
        if (!mNode.getChildren().isEmpty()) {
            for (TreeNode node : mNode.getChildren()) {
                treeView.collapseNode(node);
                collapseChildern(node,treeView);
            }
        }
    }
    

    }

    1. you call the method collapseChildern in your Holder

    @OverRide
    public void toggle(boolean active) {
    UtilityHolder.collapseOthers(mNode,treeView);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions