bmelnychuk / AndroidTreeView

AndroidTreeView. TreeView implementation for android
Apache License 2.0
3k stars 620 forks source link

Refresh Data #91

Open chendongde310 opened 8 years ago

chendongde310 commented 8 years ago

Hi guy, I want to refresh the data on the node, which method should be called?

oksimple commented 8 years ago

I only found the removeNode, can not be dynamically refreshed?

Alexander-dfzz commented 8 years ago

Hi guy, I changed the name of the node, the value has changed, but it is not able to refresh the display out, how should I do?

yoganlegendkiller commented 8 years ago

Have you found any solution guys

Brajendra commented 8 years ago

Is Any one found the solution..

bmelnychuk commented 8 years ago

Sorry guys, I don't really have much time, will do my best to implement this at the weekend

Havusoft commented 8 years ago

How to refresh a node from outside the adapter. Just save a reference to your root node when creating the tree.

for (TreeNode n : root.getChildren()) { YourAdapter adapter = (YourAdapter )n.getViewHolder(); adapter.value = anotherValue; // Update a visible field TextView tv = (TextView ) adapter.getView().findViewById(R.id.yourTextView); tv.setText("new text"); }

Brajendra commented 8 years ago

Thanks For Reply, I created the same logic for my App as you suggested.

On Tue, Oct 18, 2016 at 1:13 PM, Havusport notifications@github.com wrote:

How to refresh a node from outside the adapter. Just save a reference to your root node when creating the tree.

for (TreeNode n : root.getChildren()) { YourAdapter adapter = (YourAdapter )n.getViewHolder(); adapter.value = anotherValue; // Update a visible field TextView tv = (TextView ) adapter.getView().findViewById(R.id. yourTextView); tv.setText("new text"); }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bmelnychuk/AndroidTreeView/issues/91#issuecomment-254431401, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwYgcky6EhCMXM1GMfA0UcrnI2Enh_tks5q1HiVgaJpZM4JhvbB .

Thanks & Regards Brajendra Pandey Mobile +91-9650307763 Skypee brajendra.pandey2

gyqsophila commented 7 years ago

hey guys, I think i have a way to refresh the data of treeview: here is my code , if anyone need:

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 createView in fragment.

partho-maple commented 7 years ago

@AlphaGao1993 , Thanks for the code. That really helped.

raviyadav5951 commented 5 years ago

@AlphaGao1993 @Brajendra My use case is I am highlighting the selected node with different bg color for node. So when user rotates the device treeview loads from restoreState. and my selected node track gets lost. Any idea how this is achieved. What I have applied: I am storing the reference of selected node with the static field in Application class when user clicks on node. So when user rotates I am getting the nodes and holder(adapter) but changing the bgcolor not taking effects. Am I missing something

Priya-Patil commented 3 years ago

root.addChildren(s1) not working in api response