Hi,

*I have a list of containers where each element assigned a value in the 
"setPropertyValue" method as shown in my code:*

    private void adicionArticulo(Container cnArticulo, Articulo aRt) {

        TextArea txNombre = new TextArea();
        txNombre.setText(aRt.getNombre());
        txNombre.setEditable(false);

        Container cnElemento = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnElemento.addComponent(txNombre);
       * cnElemento.setPropertyValue("busqueda", aRt.getNombre() + 
aRt.getSerial());*

        cnArticulo.addComponent(cnElemento);
        cnArticulo.animateLayout(200);
    }

*The problem is when trying to filter the items in the container list 
because the method "getPropertyValue" comes in null*

        Container cnArticulos = new Container();
        cnArticulos.setScrollableY(true);
        devuelveArticulos(cnArticulos);

        txBusqueda.addDataChangeListener((int type, int index) -> {
            String t = txBusqueda.getText();
            if (t.length() < 1) {
                for (Component cmp : cnArticulos) {
                    cmp.setHidden(false);
                    cmp.setVisible(true);
                }
            } else {
                t = t.toLowerCase();
                for (Component cmp : cnArticulos) {
                    boolean show = false;
                    String val = null;
                    if (cmp instanceof Container) {
                        *val = (String) cmp.getPropertyValue("busqueda");*
                    }
                    show = val != null && val.toLowerCase().indexOf(t) > -1;
                    cmp.setHidden(!show);
                    cmp.setVisible(show);
                }
            }
            cnArticulos.animateLayout(250);
        });

    // Método que devuelve la lista de artículos que existen en Liber
    private void devuelveArticulos(Container cnArticulo) {

        Vector vArticulo = dT.getArticulos();
        for (int i = 0; i < vArticulo.size(); i++) {
            Articulo aRt = (Articulo) vArticulo.elementAt(i);
            adicionArticulo(cnArticulo, aRt);
        }
    }

-- 
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 [email protected].
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/83d5c07d-3475-4d27-be3b-4b29690bf3c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to