This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes LWUIT: Custom List Renderer with checkboxes to select multiple items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "LWUIT: Custom List Renderer with checkboxes to select multiple items" Watch "LWUIT: Custom List Renderer with checkboxes to select multiple items" New topic
Author

LWUIT: Custom List Renderer with checkboxes to select multiple items

Mahendr Shinde
Ranch Hand

Joined: Sep 03, 2011
Posts: 38

I am learning LWUIT from last 2/3 days. I am having problem with Custom renderer for my List (LWUIT).
For individual components, (List Items)


and this is my custom renderer:


I have tried many different ways to solve this but no success!
NOTE: code in RED color is newest addition: it makes only ONE item selected and makes other unchecked, but i don't want to uncheck other (means till the time i make them unchecked)


There is still lot to learn!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

I'm not familiar with LWUIT, but I do know that it has similarities with Swing.

In your code, you are checking the isSelected parameter, which depends on the list's selection model. I would guess that what you really need is to ignore that parameter and use the isSelected() of the SelectableListItem.

And in general, don't ever change any model state in a renderer call (nor in custom painting code, if you write any). So start by getting rid of the lineYou probably need to toggle the selected state of the SelectableListItem in a selection listener, if LWUIT has such a beast.


luck, db
There are no new questions, but there may be new answers.
Mahendr Shinde
Ranch Hand

Joined: Sep 03, 2011
Posts: 38

Thanks for your reply,
i have made few changes to my code, i have shifted logic to make checkboxes select/deselect in Action Listener and i have removed that line which you have mentioned.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: LWUIT: Custom List Renderer with checkboxes to select multiple items
 
Similar Threads
Radiobuttons in JTree
problem selecting JList item
JComboBox and "long" items rendered via HTML
table using lwuit in j2me
Change the font in a JList