DalGunBam / tree-view-list-android

Automatically exported from code.google.com/p/tree-view-list-android
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Saving the tree state #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I would like to save the state of the tree to handle runtime changes like 
orientation. I can redraw the tree by adding all the nodes again by adding all 
the nodes, but thats an overkill.  Is it possible to save the state of the tree 
and use that to redraw the tree.
thanks

Original issue reported on code.google.com by jayasund...@gmail.com on 12 Aug 2011 at 11:42

GoogleCodeExporter commented 9 years ago
Very good point indeed. I overlooked the fact that indeed the tree manager can 
be potentially big and re-creating it might be an overkill indeed. I made a few 
modifications and made a tree manager serializable, so that you can now save it 
to the bundle and -reload it from it. You can take a look at the demo activity 
- I used it to test the feature.... Right now it restores not only the nodes, 
but also state of the nodes (whether it is collapsed or not) .. You can even 
(but I leave it to you to figure out the details :)  ) to store the actual 
place in the tree that you are currently looking at (the top one or the middle 
one as you wish) and store it/restore it at rotation as well so that you will 
not have jumps when you rotate the screen. 

Original comment by ja...@potiuk.com on 13 Aug 2011 at 12:02

GoogleCodeExporter commented 9 years ago
Why does my treeView.getChildCount() returns 0 when I redraw the tree from 
savedInstanceState??
Thanks

Original comment by jayasund...@gmail.com on 15 Aug 2011 at 4:56

GoogleCodeExporter commented 9 years ago
Even though the treeView.getCount > 0, the childcount is 0. I guess that is 
because it is still not visible..any suggestions on how to make it "
visible"??

Original comment by jayasund...@gmail.com on 15 Aug 2011 at 5:16

GoogleCodeExporter commented 9 years ago
Not sure about your problem. Are you sure you set adapter for the view??? it 
should be done every time view is re-created ..... 

Original comment by jarek.po...@polidea.pl on 16 Aug 2011 at 12:17

GoogleCodeExporter commented 9 years ago
Please take  a look at the demo

Original comment by jarek.po...@polidea.pl on 16 Aug 2011 at 12:17