Sorting items in a Container performance

21 views
Skip to first unread message

State Thirteen

unread,
Oct 31, 2013, 12:52:35 PM10/31/13
to codenameone...@googlegroups.com
Hi,

I have a Container with about 300 MultiButtons in it. I need a performance friendly approach for sorting the buttons.
I try removeAll() from the container and then add new buttons and revalidate the form but it takes quite a lot of time in this case. 
I not quite understand how revalidate() works and what the correct way to use it. Same for the repaint(). 

Shai Almog

unread,
Oct 31, 2013, 4:00:42 PM10/31/13
to codenameone...@googlegroups.com
Hi,
you need to remove/add all but only invoke revalidate (or animateLayout might be nicer) in the end after finishing everything.
You can invoke layoutContainer() instead of revalidate for this particular use case since you only rearrange the elements.

State Thirteen

unread,
Oct 31, 2013, 4:04:40 PM10/31/13
to codenameone...@googlegroups.com
Should I invoke layoutContainer() only for the Container with buttons or for the form?


Shai Almog

unread,
Oct 31, 2013, 4:10:15 PM10/31/13
to codenameone...@googlegroups.com
Container with the buttons.

State Thirteen

unread,
Oct 31, 2013, 4:15:29 PM10/31/13
to codenameone...@googlegroups.com
Ok. Thanks!

On Friday, November 1, 2013 12:10:15 AM UTC+4, Shai Almog wrote:
Container with the buttons.
Reply all
Reply to author
Forward
0 new messages