How to identify List item in lwuit Form Screen?

View previous topic View next topic Go down

How to identify List item in lwuit Form Screen?

Post  andy98 on Fri May 31, 2013 7:15 pm

I've tried questions/7441725/lwuit-item-question


Container con = (Container) list.getSelectedItem();
for(int i = 0; i < con.getComponentCount(); i++){
Object obj = (Object) con.getComponentAt(i); // typecast component name instead object //ERROR


My example code:

List list = new List(createGenericListCellRendererModelData());
list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));

private Container createGenericRendererContainer() {
Container c = new Container(new BorderLayout());
Label name = new Label();
c.addComponent(BorderLayout.CENTER, name);
Label surname = new Label();
c.addComponent(BorderLayout.SOUTH, surname);
CheckBox selected = new CheckBox();
c.addComponent(BorderLayout.WEST, selected);
return c;

private Hashtable[] createGenericListCellRendererModelData() {
Hashtable[] data = new Hashtable[5];
data[0] = new Hashtable();
data[0].put("Name", "Shai");
data[0].put("Surname", "Almog");
data[0].put("Selected", Boolean.TRUE);
data[1] = new Hashtable();
data[1].put("Name", "Chen");
data[1].put("Surname", "Fishbein");
data[1].put("Selected", Boolean.TRUE);
data[2] = new Hashtable();
data[2].put("Name", "Ofir");
data[2].put("Surname", "Leitner");
data[3] = new Hashtable();
data[3].put("Name", "Yaniv");
data[3].put("Surname", "Vakarat");
data[4] = new Hashtable();
data[4].put("Name", "Meirav");
data[4].put("Surname", "Nachmanovitch");
return data;


Posts : 1
Join date : 2013-05-31

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum