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 progammatically scroll and expand to fouded item? #152

Open
michael2048 opened this issue Apr 30, 2018 · 3 comments
Open

How to progammatically scroll and expand to fouded item? #152

michael2048 opened this issue Apr 30, 2018 · 3 comments

Comments

@michael2048
Copy link

I'm try by this code

for (TreeNode tn: tView.getRoot().getChildren()) {
Log.d(TAG, ((MyHolder.IconTreeItem) tn.getValue()).getText());
if (((MyHolder.IconTreeItem) tn.getValue()).getText().toLowerCase().matches("(.)"+edFind.getText().toString().toLowerCase()+"(.)")) {
Log.d(TAG, "Совпадение " + ((MyHolder.IconTreeItem) tn.getValue()).getText());
tView.selectNode(tn, true);
}
}
not working : (

@Pirokar
Copy link

Pirokar commented Feb 4, 2019

Very interesting too.

@alierdogan7
Copy link

#128
This solution works for expanding the founded item.

@alierdogan7
Copy link

This solution worked for me to scroll to the related node..

public void scrollToNode(TreeNode currentNode, AndroidTreeView tView) {
    expandNodeBranch(tView, currentNode, false); 

    // view of the found current node
    View targetView = currentNode.getViewHolder().getView();
    targetView.getParent().requestChildFocus(targetView,targetView); // scroll to current node
}

private void expandNodeBranch(AndroidTreeView treeView, TreeNode node, boolean expand) {
        if (expand && !node.isLeaf())
            treeView.expandNode(node);
        if (node.getLevel() > 0)
            expandNodeBranch(treeView, node.getParent(), true);
    }

This was referenced Apr 15, 2020
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

3 participants