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

Asked

Viewed 32 times

1

I looked at their example on github but they show how to do a kind of input (a multiedit) for the person to type and not a label with multiple lines.

Veja como ficou o meu:

1 answer

0

This is because you are putting the text as caption (.caption), try with 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);
    }
}

Resultado do código acima

Browser other questions tagged

You are not signed in. Login or sign up in order to post.