Closed GoogleCodeExporter closed 9 years ago
The current solution can support this without any modification, it just
requires a little ingenuity on the user-end. Here's what I did:
1) Create a parent-child pair object. This serves as a unique identifier.
public class ParentChild<T>
{
private T parent;
private T child;
public ParentChild(T parent, T child)
...
2) When building your tree use the pair as the node:
ParentChild pair = new ParentChild(parents.get(level-1), node);
tree.sequentiallyAddNextNode(pair, level);
3) Ensure you pull the child from the pair for purposes of display in your
adapter:
String name = (String)((ParentChild)treeNodeInfo.getId()).getChild();
descriptionView.setText(name);
...
final CheckBox box = (CheckBox) viewLayout.findViewById(R.id.demo_list_checkbox);
box.setTag(name);
Kudos for a design that still allowed this. Perhaps this was the intention all
along? In which case I would update the 'T' definition in comments to specify
UNIQUE identifier. That way it's a little more clear what should go in there,
and make this solution more obvious. Thanks for the code!
Original comment by AMan...@gmail.com
on 2 Aug 2012 at 3:00
Thanks for the comment and investigation!
The id's were supposed to be unique across the whole tree indeed. I added that
in the comment now - I hope it will be clear to all the future devs using it :).
Original comment by ja...@potiuk.com
on 18 Aug 2012 at 10:11
Original issue reported on code.google.com by
AMan...@gmail.com
on 1 Aug 2012 at 8:54