AndroidTreeView icon indicating copy to clipboard operation
AndroidTreeView copied to clipboard

How to progammatically scroll and expand to fouded item?

Open michael2048 opened this issue 8 years ago • 3 comments

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

michael2048 avatar Apr 30 '18 02:04 michael2048

Very interesting too.

Pirokar avatar Feb 04 '19 14:02 Pirokar

#128 This solution works for expanding the founded item.

alierdogan7 avatar Apr 15 '20 21:04 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);
    }

alierdogan7 avatar Apr 15 '20 22:04 alierdogan7