views:

43

answers:

1

Hi,

I have created a custom item renderer for the tree, i have added some children in create children function, my problem is that sometimes i need to show these children and sometimes i don't, depending on clicking on a button which also i have added at create children, the problem is that i had to create the item even if i don't want it to be visible, and removed it by making visible false, and this costs a lot of memory, i have tried to create it at buttons click listener but when scrolling the child disappears, and it may appear again if i keep scrolling up and down..

i am trying to add the child just when i need it to be visible, is this possible or i have to create it on child creation method?

+1  A: 

Typically you do something like this with states. This way the components within the container (in this case your item renderer) are only created when the container enters the given state. The nice thing about taking this approach is that you can remain oblivious to when components need to be created/removed and let the states model handle that for you. Hope that helps.

Wade Mueller
this helps a lot, but i didn't find an example for the tree, could i have 3 diffrent item renderers as a view states? i mean that each state of a tree is an item renderer and a click will change the state?
seismael