LWUIT Custom expandable component in list item

230 views Asked by At

In my project I use lwuit List(main), with a custom renderer.

I`m following the purpose of implementing the expandable list item, that expands/collapses another List (wrapped).

Initially, I'd created Container with Button and List (without collapse/expand behaviour), but when I used it in main list, I faced problem with inability to select Items in wrapped list.

So, I will happy if you helps me with two problems:

  1. Can I fix it using standard lwuit tools?
  2. How can I hide my wrapped list by clicking HeaderBar (visibility just hides the content, but leaves a big gap)?

Images for clarity (ListItem - item of main List, which does not display on image):

expand view

collapsed view

private void fillForm() {
    mF = new Form();
    fillList1();
    fillList2();
    fillList();
    mF.show();
}

private void fillList() {
    mList = new CList();
    mList.setRenderer(new CRenderer());     
    mList.addItem(c1);
    mList.addItem(c2);
    mF.addComponent(c1);
    mF.addComponent(c2);
}

private void fillList1() {   
    c1 = new Container();
    b1 = new Button();      
    b1.getUnselectedStyle().setBorder(Border.createLineBorder(2, 0x000000));
    b1.addActionListener(this);
    mList1 = new List();
    mList1.setName("l1");
    mList1.setRenderer(new DefaultListCellRenderer());
    mList1.addItem("one");
    mList1.addItem("two"); 
    mList1.addItem("three");         
    mList1.addItem("four");
    mList1.addItem("five");  
    c1.addComponent(b1);
    c1.addComponent(mList1);
}    

private void fillList2() {
    c2 = new Container();
    b2 = new Button();
    b2.getUnselectedStyle().setBorder(Border.createLineBorder(2, 0x000000));             
    b2.addActionListener(this);        
    mList2 = new List();
    mList2.setName("l2");
    mList2.setRenderer(new DefaultListCellRenderer());
    mList2.addItem("путин");
    mList2.addItem("ест"); 
    mList2.addItem("детей");         
    mList2.addItem("больше чем");
    mList2.addItem("любит родину");    
    c2.addComponent(b2);
    c2.addComponent(mList2);
}    

private class CRenderer extends DefaultListCellRenderer {
    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        return (Container)value; //To change body of generated methods, choose Tools | Templates.
    }
}
1

There are 1 answers

1
Mun0n On

Can this component solve your issue?

PopupChoiceGroup