I've created the following custom list renderer for lwuit. The renderer extends a checkbox but for some reason, the select and unselect (check/uncheck) functions dont work.
If i setselected()
all the items come selected and cant be unselected.
Heres the sample code;
class TaskListRenderer extends CheckBox implements ListCellRenderer {
public TaskListRenderer() {
super();
}
public Component getListCellRendererComponent(List list, Object o, int i, boolean bln) {
Tasks task = (Tasks) o;
try {
img = Image.createImage("/three.png");
} catch (IOException ex) {
ex.printStackTrace();
}
//
setIcon(img);
setText(task.getPhoneID() + " " + task.getDate());
Style style = new Style();//(0xff0000, 0x00ff00, null, byte(128));
style.setBgColor(0xff0000);
style.setFgColor(0x00ff00);
setSelectedStyle(style);
return this;
}
public Component getListFocusComponent(List list) {
return this;
// throw new UnsupportedOperationException("Not supported yet.");
}
}