List, selected item style

38 views
Skip to first unread message

rava...@gmail.com

unread,
Oct 1, 2015, 11:23:25 AM10/1/15
to CodenameOne Discussions
Hi,
i have a very long List with over 1000 elements, when i'm scrolling i want to select an item, change it's style, and leave it selected. Then i want to continue scrolling and eventually if i select another i want it selected  (with or instead of the other element).

 How can i do this?

Shai Almog

unread,
Oct 1, 2015, 11:41:27 PM10/1/15
to CodenameOne Discussions, rava...@gmail.com
Hi,
I'm guessing that what you want is a Checkbox list?
This is automatically supported for GUI builder lists just by adding a checkbox to the entries, its also supported by the MultiList API.

Its possible to do this with a handcoded list as well by conveying the selection state to the model so it can be applied to the renderer instances.

rava...@gmail.com

unread,
Oct 2, 2015, 5:06:09 AM10/2/15
to CodenameOne Discussions, rava...@gmail.com
It's possible to get some example about it?
The second method breaks the MVC rule because i have to insert a graphic property inside the model.

Shai Almog

unread,
Oct 3, 2015, 12:53:18 AM10/3/15
to CodenameOne Discussions, rava...@gmail.com
It doesn't violate MVC since selection is a logical state not a visual state. Its entirely a model stateful attribute.
The checkbox modes do exactly this internally, if you use the GUI builder and a MultiList its just flicking a checkbox in the properties.
Reply all
Reply to author
Forward
0 new messages