Skip to content

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

Open

Description

@michael2048

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 : (

Activity

  1. Pirokar commented on Feb 4, 2019

    @Pirokar

    Very interesting too.

  2. alierdogan7 commented on Apr 15, 2020

    @alierdogan7

    #128
    This solution works for expanding the founded item.

  3. alierdogan7 commented on Apr 15, 2020

    @alierdogan7

    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);
        }
    
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