2025-01-02 11:57 AM
Hi I was wondering the recommendation on dynamically loading containers a screen vs pre populating the screen with containers. Here is the situation, when the display loads up, is receives data from a controller. The screen for the display displays x amount of container A according to what the controller sent to the screen. This can be anywhere from 0-4 instances of the container. The user may also add/remove instances of the container.
So now, according to this situation, I was thinking of dynamically populating the screen with x amount of container A. However. I am not sure whether this is recommended or not.
The other option would be to put the max number of containers possible on the screen and make them invisible. Then only make x number visible once the screen loads.
2025-01-03 02:22 AM
Hello
Good question. I think the best solution depends on your style.
It does not make a big difference for the rendering, if elements are not added or are added but invisible.
TouchGFX will walk through the added elements to find those that should be drawn, but invisible containers are quickly discarded.
Simplest code is to add the maximum number of containers, make invisible those who are not needed. In my opinion.
If you do not have a compile-time max, use a ScrollWheel.
Regards
2025-01-03 02:25 AM
Hello @Priyank ,
It is indeed not recommended to add widgets at runtime as they all require memory space and therefore it could create issues in embedded projects.
The correct way as you said is to add them all and put them invisible if you are able to do that. This would be the simplest and safest solution. However, if you want to explore the dynamic route, please find similar subjects below:
Regards,