-
Notifications
You must be signed in to change notification settings - Fork 620
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
reusing TreeNode structure #25
Comments
You can not reuse TreeNode structure, is it possible for you to re-create that structure? |
yes it is possible, but why can't we just add a method for cleaning views? |
Can you explain this bug a little more? I have the same problem and I do not think I understand the issue. I am trying to fix the issue with something like
|
@dogauzun, my idea was to force viewHolder generate new view for each node. Your way is simpler. If you want to reuse views, which have been generated already, you can remove views of first level nodes from parent layout, something like this: ((ViewGroup)mRoot.getChildren().get(0).getViewHolder().getView().getParent()).removeAllViews(); |
I solved this with the following code: //Used this treeView previously
if (treeView != null)
containerView.removeAllViews();
treeView = AndroidTreeView(getActivity(), root);
//...etc...
containerView.addView(treeView.getView()); works just fine |
None of the above solutions are working for me. I am using a fragment and I initialize the treeview when i fetch some data from the network. It works fine for the first time but getView method throws an IllegalState exception on the second time. I am recreating Treenodes and viewholders from scratch each time. |
I solved this with the following code:
|
@dogauzun I have the same issue with you. Have you fixed it now? |
I solved my problem with moving my tree initialization method from onCreateView to onStart method in my fragment. I was trying to avoid initializing my tree everytime my fragment becomes visible but in my use case the tree structure is actually not that big so I stopped trying to do that. |
None of the above solutions are working for me. Has anybody found the right solution ? |
ok On Wed, May 4, 2016 at 2:19 PM, ministorm notifications@github.com wrote:
|
This works for me. |
Thank you all of above, help me solving the problem of refresh tree node with data changed. if (layout != null) {//layout is the view you inflated in method createView,keep a reference to class field
layout.removeAllViews();
TreeNode newroot = TreeNode.root();
fillTreeData(newroot, contextEvents);
AndroidTreeView newTree = new AndroidTreeView(getActivity(), newroot);
newTree.setDefaultAnimation(true);
newTree.setDefaultViewHolder(MyTreeViewHolder.class);
newTree.setDefaultContainerStyle(R.style.TreeNodeStyle);
layout.addView(newTree.getView());
} these code can be called outside of method |
I have same question, I solved my problem with fixing IconTreeItemHolder.java |
I've created TreeNode structure and used it with AndroidTreeView. When I'm trying to reuse this structure with new AndroidTreeView I receive error
The problem is in ViewHolder. Before reusing ViewHolder we should set mView to null, but it is impossible now.
For now I have to use such hack
The text was updated successfully, but these errors were encountered: