Hi,
Sorry for my english.
I have a set of containers that move vertically efficiently.
To create a new container I use a floating button without problem.
To remove a container my idea was to make a long press on the container and
proceed to remove the container but I do not know how to do it.
To change the contents of a container my idea was to press on the container
and open a form with the information of the container and accepting to pass
the updated information returned to the container (I imagine with the
method replace). I have no problem in making the form and loading the
information but as to which container pass the information or do the
replace.
Would appreciate an example
*My code to create the container set and search is:*
Container cnCompras = new Container();
cnCompras.setScrollableY(true);
Vector vCompra2 = dT.getCompra2(cR1);
for (int i = 0; i < vCompra2.size(); i++) {
Compra2 lR2 = (Compra2) vCompra2.elementAt(i);
cnCompras.addComponent(creaContenedorCompra2(fmCompra2, cR1,
cR2));
}
txBusqueda.addDataChangeListener(new DataChangedListener() {
public void dataChanged(int type, int index) {
String t = txBusqueda.getText();
if (t.length() < 1) {
for (Component cmp : cnCompras) {
cmp.setHidden(false);
cmp.setVisible(true);
}
} else {
t = t.toLowerCase();
for (Component cmp : cnCompras) {
boolean show = false;
String val = null;
if (cmp instanceof Container) {
val = (String)
cmp5.getPropertyValue("busqueda");
}
show = val != null && val.toLowerCase().indexOf(t)
> -1;
cmp.setHidden(!show);
cmp.setVisible(show);
}
}
cnCompras.animateLayout(250);
}
}
);
*The "creaContenedorCompra2" method has the following code:*
private Container creaContenedorCompra2(Form fmCompra2, Compra1 lR1,
Compra2 lR2) {
TextArea articulo = new TextArea(2, 70);
Label lbCantidad = new Label();
Label lbPrecio = new Label();
Label lbMonto = new Label();
Label lbUM = new Label();
TextArea cantidad = new TextArea();
TextArea precio = new TextArea();
TextArea monto = new TextArea();
TextArea uM = new TextArea(1, 7);
articulo.setUIID("MultiLine2");
articulo.setFocusable(true);
articulo.setEditable(false);
articulo.setAlignment(TextArea.LEFT);
articulo.setPropertyValue("serial", lR2.getSerial());
lbCantidad.setText(idioma.getCantidad() + ":");
lbCantidad.setUIID("MultiLine3");
cantidad.setUIID("MultiLine3");
cantidad.setFocusable(true);
cantidad.setEnabled(true);
lbPrecio.setText(idioma.getPrecio() + ":");
lbPrecio.setUIID("MultiLine3");
precio.setUIID("MultiLine3");
precio.setFocusable(true);
precio.setEnabled(true);
lbMonto.setText(idioma.getMonto() + ":");
lbMonto.setUIID("MultiLine3");
monto.setUIID("LabelTotalBig");
monto.setText("00.00");
monto.setFocusable(true);
monto.setEnabled(true);
monto.setAlignment(TextArea.RIGHT);
lbUM.setText(idioma.getUM() + ":");
lbUM.setUIID("MultiLine3");
uM.setUIID("MultiLine3");
uM.setFocusable(true);
uM.setEnabled(true);
Button lbImagen = new Button() {
@Override
public void longPointerPress(int x, int y) {
super.longPointerPress(x, y);
*// * * Delete Container *
}
@Override
public void addActionListener(ActionListener l) {
super.addActionListener(l); //To change body of generated
methods, choose Tools | Templates.
*// Shows in a form the contents of a container is and when
accepting passes the information of the form to container.*
}
};
lbImagen.setUIID("TransparentButton");
articulo.setText(lR2.getNombreArticulo());
uM.setText(lR2.getUnidadMedida());
Double cnt = lR2.getCantidad();
Double pre = lR2.getPrecio();
Double mnt = 0.0;
mnt = pre * cnt;
cantidad.setText(Double.toString(cnt));
precio.setText(Double.toString(pre));
if (mnt == 0) {
monto.setText(" 0.00");
} else {
monto.setText(Double.toString(mnt));
}
if (pre > 0d) {
articulo.setUIID("MultiLine2Resaltado");
} else {
articulo.setUIID("MultiLine2");
}
if (lR2.getCarpetaImagenCategoria().equals("")) {
lR2.setCarpetaImagenCategoria("generico.png");
}
try {
lbImagen.setIcon(Image.createImage("/" +
lR2.getCarpetaImagenCategoria()));
} catch (IOException ex) {
try {
lbImagen.setIcon(Image.createImage("/generico.png"));
} catch (IOException ex1) {
Dialog.show(idioma.getError(), ex1.getMessage(),
idioma.getContinuar(), null);
}
}
Container cnCantidad = new Container(new
BoxLayout(BoxLayout.Y_AXIS));
cnCantidad.addComponent(lbCantidad);
cnCantidad.addComponent(cantidad);
Container cnPrecio = new Container(new BoxLayout(BoxLayout.Y_AXIS));
cnPrecio.addComponent(lbPrecio);
cnPrecio.addComponent(precio);
BorderLayout border = new BorderLayout();
border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
Container cnMonto = new Container();
cnMonto.setLayout(new BorderLayout());
cnMonto.setLayout(border);
cnMonto.addComponent(BorderLayout.CENTER, monto);
cnMonto.setUIID("LabelTotalBig");
Container cnUM = new Container(new BoxLayout(BoxLayout.Y_AXIS));
cnUM.addComponent(lbUM);
cnUM.addComponent(uM);
Container cnInfo = new Container();
cnInfo.setLayout(new GridLayout(1, 3));
cnInfo.addComponent(cnUM);
cnInfo.addComponent(cnCantidad);
cnInfo.addComponent(cnPrecio);
Container cnDatos = new Container(new BoxLayout(BoxLayout.Y_AXIS));
cnDatos.addComponent(articulo);
cnDatos.addComponent(cnInfo);
Container cnS1 = new Container(new BorderLayout());
cnS1.setLayout(new BoxLayout(BoxLayout.X_AXIS));
cnS1.getStyle().setBorder(Border.createBevelRaised());
cnS1.addComponent(new Label());
Container cnS2 = new Container(new BorderLayout());
cnS2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
cnS2.getStyle().setBorder(Border.createBevelRaised());
cnS2.addComponent(new Label(""));
Container cnPreItem = new Container(new
BoxLayout(BoxLayout.X_AXIS));
cnPreItem.addComponent(lbImagen);
cnPreItem.addComponent(cnDatos);
Container cnItem = new Container();
cnItem.setLayout(new BorderLayout());
cnItem.addComponent(BorderLayout.CENTER, cnPreItem);
cnItem.addComponent(BorderLayout.EAST, cnMonto);
Container cnDato = new Container();
cnDato.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
cnDato.addComponent(cnItem);;
cnDato.addComponent(cnS1);
cnDato.setPropertyValue("busqueda", lR2.getNombreArticulo() +
lR2.getSerial());
cnDato.setLeadComponent(lbImagen);
return cnDato;
}
--
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/c3734320-f76b-4a72-8867-7e00ca41f342%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.