bmelnychuk / AndroidTreeView

AndroidTreeView. TreeView implementation for android
Apache License 2.0
2.99k stars 618 forks source link

wrong selected count #172

Open xleix opened 5 years ago

xleix commented 5 years ago

When the parent node is not expanded, androidTreeView.getSelected() cannot get the correct selection when the parent node is checked.

MaggiWuerze commented 4 years ago

This seems to be a general issue with getting sizes from the tree, root.size is also affected. I solved it by expanding and then collapsing all nodes before the view gets rendered. After that you can check the selected.size successfully, but you still need to count your nodes on your own

OleksandrAndro commented 4 years ago

I had same issue, but in my case it was, when my menu has more than 2 children trees, so I added such block after the line https://github.com/bmelnychuk/AndroidTreeView/blob/d051ce75f5c9bd5206481808f6133b51f581c8f1/app/src/main/java/com/unnamed/b/atv/sample/holder/SelectableHeaderHolder.java#L48: if(n.getChildren().size()!=0){ for (TreeNode m : n.getChildren()) { getTreeView().selectNode(m, isChecked); } }