<https://lh3.googleusercontent.com/-HZLlzS99EBM/Wgk6MP6A_NI/AAAAAAAAAK8/PwhVxvkuUBsIJ9X1YPUQh1_hp9sdGvA3gCLcBGAs/s1600/CodenameOne%2BScreenshot%2B61.png>
 
<https://lh3.googleusercontent.com/-Ql14oef5Acw/Wgk6Q6SHwzI/AAAAAAAAALA/JXeO59d_XhwFQUCazHkYqrziZk8mqxNnQCLcBGAs/s1600/CodenameOne%2BScreenshot%2B62.png>
Hi,

I have an app that works correctly in the simulator, but in an Android 
phone there is a single function that does not work for some reason.
I am including 2 images: The first one shows a list of Stores and in the 
lower part appears a button that creates a new record. When pressed in the 
simulator the application goes to the next form but in the cell phone it 
only changes the color of the "+" button without making any other change. 
The second image is the new form that can be visualized in the simulator 
but not in the cell phone.

I am including 2 methods of my code:


    //Método que muestra la lista de Artículos y permite dar mantenimiento 
a los mismos incluyendo
    //su relación con otros artículos
    *private void muestraArticulos(final Form fmLiber)* {

        Form fmArticulo = new Form(new BorderLayout());
        final Toolbar tbMenu = new Toolbar();
        fmArticulo.setToolBar(tbMenu);
        tbMenu.setBackCommand("", e -> fmLiber.showBack());
        tbMenu.getStyle().setAlignment(Label.LEFT);

        final TextField txBusqueda = new TextField("", 
idioma.getMensaje26());
        txBusqueda.setUIID("Title");
        txBusqueda.getAllStyles().setAlignment(Component.CENTER);
        Label lbTitulo = new Label(idioma.getArticulos() + " ", "Title");
        Container cnTitulo = new Container(BoxLayout.x());
        cnTitulo.addComponent(lbTitulo);
        cnTitulo.addComponent(txBusqueda);
        tbMenu.setTitleComponent(cnTitulo);
        tbMenu.getTitleComponent().getStyle().setAlignment(Label.LEFT);

        Style s = UIManager.getInstance().getComponentStyle("Title");
        FontImage iBusqueda = 
FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
        tbMenu.addCommandToRightBar(new Command("", iBusqueda) {
            @Override
            public void actionPerformed(ActionEvent evt) {
                txBusqueda.startEditingAsync();
            }
        });

        FontImage iSerial = (FontImage) 
FontImage.createMaterial(FontImage.MATERIAL_LINE_WEIGHT, s).rotate(90);
        tbMenu.addCommandToRightBar(new Command("", iSerial) {
            @Override
            public void actionPerformed(ActionEvent evt) {
                lectorCodigo(txBusqueda, iU);
            }
        });

        FontImage iInformacion = 
FontImage.createMaterial(FontImage.MATERIAL_INFO, s);
        tbMenu.addCommandToRightBar(new Command("", iInformacion) {
            @Override
            public void actionPerformed(ActionEvent evt) {
                muestraInformacion(fmArticulo, idioma.getArticulos() + " / 
" + idioma.getSimilares(), idioma.getMensaje71() + idioma.getMensaje70());
            }
        });

        Container cnArticulos = creaArticulo(fmArticulo);
        cnArticulos.setScrollableY(true);
        setCnArticulos(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.getClientProperty("busqueda");
                    }
                    show = val != null && val.toLowerCase().indexOf(t) > -1;
                    cmp.setHidden(!show);
                    cmp.setVisible(show);
                }
            }
            cnArticulos.animateLayout(250);
        });

        FloatingActionButton btNuevo = 
FloatingActionButton.createFAB(FontImage.MATERIAL_ADD);
        btNuevo.setVerticalAlignment(Label.BOTTOM);
        btNuevo.setTextPosition(Label.BOTTOM);
        btNuevo.bindFabToContainer(fmArticulo.getContentPane(), 
Component.RIGHT, Component.BOTTOM);
        btNuevo.setAlignment(Label.CENTER);
        btNuevo.addActionListener((e) -> {
            Articulo aRt = new Articulo();
           * actualizaArticulo(fmArticulo, cnArticulos, aRt, ADICIONAR);*
        });

        fmArticulo.addComponent(BorderLayout.CENTER, cnArticulos);
        fmArticulo.setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_VERTICAL, true, 500));
        fmArticulo.show();
    }

    // Método que permite dar mantenimiento a los Items de Artículos
*    private void actualizaArticulo(final Form fmArticulo, Container 
cnItem, final Articulo aRt, final int modo) {*

        final Form fmDetalle = new Form(new BorderLayout());
        fmDetalle.setTitle(idioma.getMensaje12());
        fmDetalle.setScrollableY(true);

        final TextArea txNombreCorto = new TextArea();;
        TextArea txTamano = new TextArea();
        TextArea txEmpresa = new TextArea();
        TextField txSerial = new TextField();

        txNombreCorto.setHint(idioma.getMensaje54());
        txTamano.setHint(idioma.getMensaje56());
        txEmpresa.setHint(idioma.getMensaje55());

        final ComboBox cbCategoria = new ComboBox();
        DefaultListModel lmCategoria = new 
DefaultListModel(idioma.getCategorias());
        cbCategoria.setModel(lmCategoria);
        cbCategoria.setListCellRenderer(new Formato(LISTA_CATEGORIA, res));

        final ComboBox cbSubCategoria = new ComboBox();

        final CheckBox cbImpuesto = new CheckBox(idioma.getMensaje14());
        cbImpuesto.setOppositeSide(true);
        cbImpuesto.setHandlesInput(true);

        Label lbCategoria = new Label(idioma.getCategoria() + ":");
        Label lbSubCategoria = new Label(idioma.getSubCategoria() + ":");
        Label lbSerial = new Label(idioma.getSerial() + ":");

        if (modo == CAMBIAR) {
            fmDetalle.setTitle(idioma.getMensaje20());
            txNombreCorto.setText(aRt.getNombreCorto());
            txTamano.setText(aRt.getTamano());
            txEmpresa.setText(aRt.getEmpresa());
            txSerial.setText(aRt.getSerial());
            
cbCategoria.setSelectedIndex(posicionCategoria(aRt.getCategoria()));
            String[] lSubCategoria = 
obtenSubCategoria(cbCategoria.getSelectedItem(), idioma.getCategorias());
            DefaultListModel lmSubCategoria = new 
DefaultListModel(lSubCategoria);
            cbSubCategoria.setModel(lmSubCategoria);
            cbSubCategoria.setListCellRenderer(new 
Formato(LISTA_SUBCATEGORIA, res));
            
cbSubCategoria.setSelectedIndex(posicionSubCategoria(aRt.getCategoria(), 
aRt.getSubCategoria()));

            if (aRt.getImpuesto() == 1) {
                cbImpuesto.setSelected(true);
            } else {
                cbImpuesto.setSelected(false);
            }
        }
        cbCategoria.addActionListener((e) -> {
            String[] lSubCategoria = 
obtenSubCategoria(cbCategoria.getSelectedItem(), idioma.getCategorias());
            DefaultListModel lmSubCategoria = new 
DefaultListModel(lSubCategoria);
            cbSubCategoria.setModel(lmSubCategoria);
        });
        Container cnOriginal = originalSimilares(aRt.getArticulo(), 
txNombreCorto.getText());
        Container cnSimilar = new ComponentGroup();
        posiblesSimilares(cnSimilar, aRt.getArticulo(), 
txNombreCorto.getText());

        txNombreCorto.addActionListener((e) -> {
            posiblesSimilares(cnSimilar, aRt.getArticulo(), 
txNombreCorto.getText());
            txNombreCorto.setFocus(true);
        });

        final Toolbar tbMenu = new Toolbar();
        fmDetalle.setToolBar(tbMenu);
        tbMenu.setBackCommand("", e -> fmArticulo.showBack());
        if (modo == ADICIONAR) {
            tbMenu.setTitle(idioma.getNuevo() + " " + idioma.getArticulo());
        } else {
            tbMenu.setTitle(idioma.getCambiar() + " " + 
idioma.getArticulo());
        }

        Style s = UIManager.getInstance().getComponentStyle("Menu");
        FontImage iSerial = (FontImage) 
FontImage.createMaterial(FontImage.MATERIAL_LINE_WEIGHT, s).rotate(90);
        Button btSerial = new Button(iSerial, "Transparent");
        btSerial.setVerticalAlignment(Label.BOTTOM);
        btSerial.setAlignment(CENTER);
        btSerial.setTextPosition(Label.BOTTOM);
        btSerial.addActionListener((e) -> {
            lectorCodigo(txSerial, iU);
        });

        Button btConfirmar = new Button(idioma.getConfirmar(), 
"ButtonBlue");
        btConfirmar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {

                Articulo aTt = new Articulo();
                aTt.setNombreCorto(txNombreCorto.getText());
                aTt.setSerial(txSerial.getText());
                if (txNombreCorto.getText() == null || 
txNombreCorto.getText().equals("")) {
                    Dialog.show(idioma.getError(), idioma.getNombreCorto() 
+ " " + idioma.getMensaje6(), idioma.getContinuar(), null);
                    return;
                }
                if (txTamano.getText() == null || 
txTamano.getText().equals("")) {
                    Dialog.show(idioma.getError(), idioma.getTamano() + " " 
+ idioma.getMensaje6(), idioma.getContinuar(), null);
                    return;
                }
                if (txEmpresa.getText() == null || 
txEmpresa.getText().equals("")) {
                    Dialog.show(idioma.getError(), idioma.getEmpresa() + " 
" + idioma.getMensaje6(), idioma.getContinuar(), null);
                    return;
                }
                if (txSerial.getText() == null || 
txSerial.getText().equals("")) {
                    Dialog.show(idioma.getError(), idioma.getSerial() + " " 
+ idioma.getMensaje6(), idioma.getContinuar(), null);
                    return;
                }
                if (modo == ADICIONAR) {
                    if (enArticulo(aTt, ARTICULO_LEE_SERIAL)) {
                        Dialog.show(idioma.getError(), idioma.getSerial() + 
" " + idioma.getMensaje58(), idioma.getContinuar(), null);
                        return;
                    }
                    validaSimilares(aTt);
                    if (iU.getResultado().equals(NO_REALIZADO)) {
                        return;
                    }
                }
                if (modo == CAMBIAR) {
                    if (!txSerial.getText().equals(aRt.getSerial())) {
                        if (enArticulo(aTt, ARTICULO_LEE_SERIAL)) {
                            Dialog.show(idioma.getError(), 
idioma.getSerial() + " " + idioma.getMensaje58(), idioma.getContinuar(), 
null);
                            return;
                        }
                    }
                }
                actualizaSimilares(cnSimilar, cnOriginal, 
aRt.getArticulo());
                switch (modo) {
                    case ADICIONAR:
                        Articulo aR = new Articulo();
                        aR.setArticulo(regresaLlave(ARTICULO, iU));
                        aR.setNombre(txNombreCorto.getText() + " " + 
txTamano.getText() + " " + txEmpresa.getText());
                        aR.setNombreCorto(txNombreCorto.getText());
                        aR.setTamano(txTamano.getText());
                        aR.setEmpresa(txEmpresa.getText());
                        aR.setSerial(txSerial.getText());
                        
aR.setCategoria(obtenNombreCategoria(cbCategoria.getSelectedItem()));
                        
aR.setSubCategoria(obtenSubCategoria(cbSubCategoria.getSelectedItem()));
                        if (cbImpuesto.isSelected()) {
                            aR.setImpuesto(1);
                        } else {
                            aR.setImpuesto(0);
                        }
                        aR.setUsuarioCambio(iU.getIdUsuario());
                        SimpleDateFormat sFormato = new 
SimpleDateFormat("yyyy-MM-dd");
                        Date fecha = new Date();
                        sFormato.format(fecha);
                        aR.setFechaCambio(sFormato.format(fecha));
                        aR.setCondicion(REGISTRO_NUEVO);
                        aR.setSincronizado(false);
                        aR.setEstado(ACTIVO);
                        dT.actualizarDatos(ARTICULO_ADICIONA, aR, true);
                        if (iU.getResultado().equals(REALIZADO)) {
                            Vector vArticulo = dT.getArticulos();
                            vArticulo.addElement(aR);
                            dT.setArticulos(vArticulo);
                            Container cnArticulos = getCnArticulos();
                            Container cnArticulo = 
creaItemArticulo(fmArticulo, aR);
                            cnArticulos.addComponent(cnArticulo);
                            cnArticulos.animateLayout(200);
                        } else {
                            Dialog.show(idioma.getError(), 
idioma.getMensaje45(), idioma.getContinuar(), null);
                        }
                        break;
                    case CAMBIAR:
                        aRt.setNombre(txNombreCorto.getText() + " " + 
txTamano.getText() + " " + txEmpresa.getText());
                        aRt.setNombreCorto(txNombreCorto.getText());
                        aRt.setTamano(txTamano.getText());
                        aRt.setEmpresa(txEmpresa.getText());
                        aRt.setSerial(txSerial.getText());
                        
aRt.setCategoria(obtenNombreCategoria(cbCategoria.getSelectedItem()));
                        
aRt.setSubCategoria(obtenSubCategoria(cbSubCategoria.getSelectedItem()));
                        if (cbImpuesto.isSelected()) {
                            aRt.setImpuesto(1);
                        } else {
                            aRt.setImpuesto(0);
                        }
                        aRt.setUsuarioCambio(iU.getIdUsuario());
                        sFormato = new SimpleDateFormat("yyyy-MM-dd");
                        fecha = new Date();
                        sFormato.format(fecha);
                        aRt.setFechaCambio(sFormato.format(fecha));
                        aRt.setCondicion(REGISTRO_MODIFICADO);
                        aRt.setSincronizado(false);
                        dT.actualizarDatos(ARTICULO_ACTUALIZA, aRt, true);
                        if (iU.getResultado().equals(REALIZADO)) {
                            Vector vArticulo = dT.getArticulos();
                            for (int i = 0; i < vArticulo.size(); i++) {
                                aR = (Articulo) vArticulo.elementAt(i);
                                if 
(aR.getArticulo().equals(aRt.getArticulo())) {
                                    vArticulo.setElementAt(aRt, i);
                                    break;
                                }
                            }
                            dT.setArticulos(vArticulo);
                            Container cnOriginal = 
creaItemArticulo(fmArticulo, aRt);
                            cnArticulos = getCnArticulos();
                            cnArticulos.replace(cnItem, cnOriginal, null);
                        } else {
                            Dialog.show(idioma.getError(), 
idioma.getMensaje45(), idioma.getContinuar(), null);
                        }

                        break;
                }

                fmArticulo.revalidate();
                fmArticulo.showBack();
            }
        }
        );

        Label lbNombreCorto = new Label(idioma.getNombreCorto() + ":");
        Container cnNombreCorto = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnNombreCorto.addComponent(lbNombreCorto);
        cnNombreCorto.addComponent(txNombreCorto);

        Label lbTamano = new Label(idioma.getTamano() + ":");
        Container cnTamano = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnTamano.addComponent(lbTamano);
        cnTamano.addComponent(txTamano);

        Label lbEmpresa = new Label(idioma.getEmpresa() + ":");
        Container cnEmpresa = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnEmpresa.addComponent(lbEmpresa);
        cnEmpresa.addComponent(txEmpresa);

        Container cnEmp = new Container(new GridLayout(1, 2));
        cnEmp.addComponent(cnTamano);
        cnEmp.addComponent(cnEmpresa);

        Container cnNombre = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));;
        cnNombre.addComponent(cnNombreCorto);
        cnNombre.addComponent(cnEmp);

        Label lbSimilares = new Label(idioma.getSimilares() + ":");
        Container cnSimilares = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnSimilares.addComponent(lbSimilares);
        cnSimilares.addComponent(cnSimilar);

        Container cnSerial1 = new Container(new BorderLayout());
        cnSerial1.addComponent(BorderLayout.WEST, btSerial);
        cnSerial1.addComponent(BorderLayout.CENTER, txSerial);

        Container cnSerial = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnSerial.addComponent(lbSerial);
        cnSerial.addComponent(cnSerial1);

        Container cnCategoria = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnCategoria.addComponent(lbCategoria);
        cnCategoria.addComponent(cbCategoria);

        Container cnSubCategoria = new Container(new 
BoxLayout(BoxLayout.Y_AXIS));
        cnSubCategoria.addComponent(lbSubCategoria);
        cnSubCategoria.addComponent(cbSubCategoria);

        Container cnCat = new Container(new GridLayout(1, 2));
        cnCat.addComponent(cnCategoria);
        cnCat.addComponent(cnSubCategoria);

        Container cnCentro = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnCentro.setScrollableY(true);
        cnCentro.addComponent(cnNombre);
        cnCentro.addComponent(cnSerial);

        cnCentro.addComponent(cnCat);
        cnCentro.addComponent(cbImpuesto);
        cnCentro.addComponent(separador());
        cnCentro.addComponent(cnSimilares);

        fmDetalle.addComponent(BorderLayout.CENTER, cnCentro);
        fmDetalle.addComponent(BorderLayout.SOUTH, btConfirmar);
        fmDetalle.setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_VERTICAL, true, 500));
        fmDetalle.show();
    }

-- 
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/a46f9153-4a40-44a0-87f0-80f064553734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to