In totalcross, how do I show a popup when I click a button inside an accordion?

1

I have an application with Totalcross, I'm using the accordion and inside every abba I have a refresh button, how do I do when I click the refresh button to see a popup with an "updated data" message? I tried using "addPenListener" and "onEvent" but it did not work.

    
asked by anonymous 09.11.2018 / 15:47

1 answer

1

It would be good for you to send your code to understand where you went wrong when you used onEvent. Already with the addPenListener, you must have confused with addPressListener.

Follow the code for creating an accordion with a Button inside, which when you click fires a popup with a message.

public class AccordionTela extends Container {

AccordionContainer ac;
Label lb;

public AccordionTela(){
    setBackColor(Color.WHITE);
}

public void initUI(){
    ac = new AccordionContainer();
    ac.setFont(font.asBold());

    add(ac, CENTER, TOP+30, PARENTSIZE+85, PREFERRED);
    ac.setBackForeColors(0xadd8e6,Color.BLACK);
    ac.add(ac.new Caption("Legenda"), LEFT, TOP, FILL, PREFERRED);

    lb = new Label("Texto");
    ac.add(lb,LEFT,AFTER,FILL,PREFERRED);

    Button bt = new Button("botão");
    bt.setBackForeColors(Color.WHITE, Color.BLACK);
    ac.add(bt,LEFT,AFTER,PREFERRED+10,PREFERRED+10);

    bt.addPressListener(e -> {
        new MessageBox("Aviso","Dados atualizados").popup();
    });
}

}
    
09.11.2018 / 15:54