AndroidTreeView
AndroidTreeView copied to clipboard
How to progammatically scroll and expand to fouded item?
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 : (
Very interesting too.
#128 This solution works for expanding the founded item.
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);
}