Long press on container list

23 views
Skip to first unread message

rube...@yahoo.com

unread,
Nov 10, 2016, 5:01:06 PM11/10/16
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Hi,

I can not make it work.

My code:

    private Container creaContenedorLista1(Lista1 lR1) {
        Label lbImagen = new Label();
        Button nombre = new Button();
        SpanLabel descripcion = new SpanLabel();

        nombre.setUIID("MultiLine2");
        nombre.setFocusable(true);

        descripcion.setUIID("MultiLine3");
        descripcion.setFocusable(true);
        Container cnNombre = new Container(new BoxLayout(BoxLayout.X_AXIS));
        cnNombre.addComponent(nombre);

        Container cnDatos = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnDatos.addComponent(cnNombre);
        cnDatos.addComponent(descripcion);

        Container cnItem = new Container(new BoxLayout(BoxLayout.X_AXIS));
        cnItem.addComponent(lbImagen);
        cnItem.addComponent(cnDatos);

        Container cnS1 = new Container(new BorderLayout());
        cnS1.setLayout(new BoxLayout(BoxLayout.X_AXIS));
        cnS1.getStyle().setBorder(Border.createBevelLowered());
        cnS1.addComponent(new Label());

        Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnt.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        cnt.addComponent(cnItem);;
        cnt.addComponent(cnS1);
        cnt.setLeadComponent(nombre);
        nombre.setText(lR1.getNombre());
        descripcion.setText(lR1.getDescripcion());
        try {
            lbImagen.setIcon(Image.createImage("/" + imagenItem(lR1.getTipoLista())));
        } catch (IOException ex) {
            Dialog.show("Error", ex.getMessage(), "Continuar", null);
        }
        nombre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                if (ae.isLongEvent()) {
                    Dialog.show("Prueba", "Espera por mucho tiempo", "continuar", null);
                } else {
                    Dialog.show("Prueba1", "Rápido", "continuar", null);
                }
            }
        });
        return cnt;
    }

Shai Almog

unread,
Nov 11, 2016, 12:37:33 AM11/11/16
to CodenameOne Discussions, rube...@yahoo.com
We deprecated ContainerList a while back, it never supported long press anyway.

rvill...@cableonda.com

unread,
Nov 12, 2016, 2:24:37 PM11/12/16
to CodenameOne Discussions, rube...@yahoo.com
Hi,

I am confused, in the blog of August 22 (https://www.codenameone.com/blog/avoiding-lists.html)  is encouraged to use the list of containers instead of the list. Could you clarify this please.

Thanks

Shai Almog

unread,
Nov 12, 2016, 10:21:36 PM11/12/16
to CodenameOne Discussions, rube...@yahoo.com, rvill...@cableonda.com
Hi,
There is a class called ContainerList which you should not use, I went thru your question quickly and didn't notice the source.

I suggest not using that name and just using Container.

The way to handle long press is override the components longPress callback method.
Reply all
Reply to author
Forward
0 new messages