How do I create a simple multiline accordion with Java and Totalcross?

1

I looked at their example in github but they show how to make a kind of input (a multiedit) for the person to type and not a multiline label.

    
asked by anonymous 01.11.2018 / 14:20

1 answer

0

This happens because you're putting the text as caption ( .caption ), try the code below.

public class AccordionSample extends MainWindow{

    public AccordionSample(){
        setUIStyle(Settings.MATERIAL_UI);
    }

    public void initUI(){
        AccordionContainer.Group gr = new AccordionContainer.Group();
        AccordionContainer ac[] = new AccordionContainer[5];
        Label lb = new Label("Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Vivamus pellentesque massa \nnon magna maximus fermentum."
                + " \nNunc condimentum tempor odio, in dictum \nneque sollicitudin sit amet. Sed ut venenatis \nsem."
                + " \nMorbi sagittis purus fringilla, suscipit lorem \nquis, cursus ipsum. Donec sodales rutrum \nrisus, ac sagittis est laoreet ac. "
                + "\nCurabitur egestas leo.");

        ac[0] = new AccordionContainer(gr);
        ac[0].setFont(font.asBold());

        add(ac[0],LEFT+10,CENTER,PARENTSIZE+95,PARENTSIZE+43);
        ac[0].setBackForeColors(0X757575, 0Xffffff);
        ac[0].add(ac[0].new Caption("Any Text:"), LEFT+5, TOP, FILL, PREFERRED);
        ac[0].add(lb,LEFT+5,TOP+22,FILL,PREFERRED);
    }
}

    
01.11.2018 / 15:54