Hi,

Inside my app create a section to show non-invasive ads. The addresses of 
these ads are in a database and every time you enter this section the 
database is read again. Change the addresses of the images in the Database 
but the images do not refresh on the buttons.

My Code:
    private void formaOfertas(Container cnOfertas, ArrayList aAnuncios) {

        cnOfertas.removeAll();
        cnOfertas.setScrollableY(true);
        Container cntB = new Container();
        int size = Display.getInstance().convertToPixels(15);
        int ancho = Display.getInstance().getDisplayWidth();
        ancho = (int) (ancho - (ancho * 0.03d));
        boolean ciclo = true;
        int c = 2;
        while (ciclo) {
            c++;
            size = (int) (ancho / c);
            int r = ancho % c;
            if (r <= 0 || c >= aAnuncios.size()) {
                ciclo = false;
            }
        }

        Button bt[];
        bt = new Button[aAnuncios.size()];
        for (int i = 0; i < aAnuncios.size(); i++) {
            Campana1 cM1 = (Campana1) aAnuncios.get(i);
            bt[i] = new Button();
            bt[i].setUIID("Label");
            Image img;
            if (cM1.getRutaLogo().equals("") || 
cM1.getRutaLogo().equals("null")) {
                img = res.getImage("promo.png").scaled(size, size);
            } else {
                EncodedImage lugar = 
EncodedImage.createFromImage(Image.createImage(size, size, 0xffcccccc), 
true);
                img = URLImage.createToStorage(lugar, 
Integer.toString(cM1.getCampana()), cM1.getRutaLogo());
            }
            bt[i].setIcon(img);
            cntB.addComponent(bt[i]);

            bt[i].addActionListener((e) -> {
                Display.getInstance().execute(cM1.getEnlace());
            });
        }
        Container cnCentro = new Container(new 
BoxLayout(BoxLayout.Y_AXIS)).add(cntB);
        cnOfertas.add(BorderLayout.CENTER, cnCentro);
    }

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/bc3ced80-bd0b-4501-9f93-83c048bff24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to