Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to collapse other node expect current node clicked #156

Open
vinhgroup opened this issue Jun 19, 2018 · 1 comment
Open

How to collapse other node expect current node clicked #156

vinhgroup opened this issue Jun 19, 2018 · 1 comment

Comments

@vinhgroup
Copy link

vinhgroup commented Jun 19, 2018

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

thanks in advance

@vinhgroup vinhgroup changed the title How to collapse other not expect current node clicked How to collapse other node expect current node clicked Jun 19, 2018
@brunopizzo
Copy link

brunopizzo commented Jun 15, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants