Hi,
Create a small app to show my problem. When you press the security icon (in
the menu bar) a new record is created in a vector. The list of containers
can be seen by executing the "muestraPrueba" method from the list of
commands ("Validate"). This list is not displayed on the "Tab" component.
I'm really frustrated because I have 4 weeks with the problem and I can not
find the solution.
My code below:
public class Liber {
private Form current;
private Resources theme;
private Datos dT;
private Container cnLiber1;
private Container cnLiber2;
private Container cnLiber3;
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
}
public void start() {
if (current != null) {
current.show();
return;
}
dT = Datos.getInstancia();
muestraLiber();
}
public void stop() {
current = Display.getInstance().getCurrent();
if (current instanceof Dialog) {
((Dialog) current).dispose();
current = Display.getInstance().getCurrent();
}
}
public void destroy() {
}
// Método que muestra la Forma Principal
private void muestraLiber() {
final Form fmLiber = new Form();
fmLiber.setTitle("Prueba");
fmLiber.setLayout(new BorderLayout());
Command cmdSalir = new Command("Salir") {
public void actionPerformed(ActionEvent ev) {
Display.getInstance().exitApplication();
}
};
final Toolbar tbMenu = new Toolbar();
fmLiber.setToolBar(tbMenu);
Style s = UIManager.getInstance().getComponentStyle("Title");
FontImage iNuevo =
FontImage.createMaterial(FontImage.MATERIAL_SECURITY, s);
tbMenu.addCommandToRightBar(new Command("", iNuevo) {
@Override
public void actionPerformed(ActionEvent evt) {
Vector vDato = dT.getDato();
vDato.addElement("Record ");
dT.setDato(vDato);
Dialog.show("New", "Add The New Record", "Continue", null);
}
});
Command cmdValidacion = new Command("Validar") {
public void actionPerformed(ActionEvent ev) {
muestraPrueba(fmLiber);
}
};
tbMenu.addCommandToOverflowMenu(cmdValidacion);
cnLiber1 = muestraCompra1();
cnLiber2 = muestraCompra1();
cnLiber3 = muestraCompra1();
final Tabs tsMenu = new Tabs();
tsMenu.addTab("Compras", cnLiber1);
tsMenu.addTab("Listas", cnLiber2);
tsMenu.addTab("Novedades", cnLiber3);
tsMenu.addSelectionListener(new SelectionListener() {
@Override
public void selectionChanged(int oldSelected, int newSelected) {
if (newSelected == 0) {
cnLiber1 = muestraCompra1();
}
if (newSelected == 1) {
cnLiber2 = muestraCompra1();
}
if (newSelected == 2) {
cnLiber3 = muestraCompra1();
}
}
});
fmLiber.addComponent(BorderLayout.CENTER, tsMenu);
fmLiber.setBackCommand(cmdSalir);
fmLiber.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL,
true, 500));
fmLiber.show();
fmLiber.revalidate();
}
private Container muestraCompra1() {
Container compra1 = new Container(BoxLayout.y());
compra1.setScrollableY(true);
compra1.setUIID("Form");
Vector vDato = dT.getDato();
for (int i = 0; i < vDato.size(); i++) {
compra1.add(creaContenedorCompra("Prueba" + i));
}
return compra1;
}
private Container creaContenedorCompra(String dato) {
Container cn = new Container(new BorderLayout());
cn.addComponent(BorderLayout.CENTER, new Label(dato));
return cn;
}
private void muestraPrueba(final Form fmLiber) {
final Form fmPrueba = new Form();
fmPrueba.setLayout(new BorderLayout());
fmPrueba.setScrollable(false);
Command cmdVolver = new Command("Volver") {
public void actionPerformed(ActionEvent ev) {
fmLiber.showBack();
}
};
Container cn2 = muestraCompra1();
fmPrueba.addComponent(BorderLayout.CENTER, cn2);
fmPrueba.setBackCommand(cmdVolver);
fmPrueba.setTransitionOutAnimator(CommonTransitions.createSlide(
CommonTransitions.SLIDE_HORIZONTAL, true, 500));
fmPrueba.show();
}
}
public class Datos {
private static Datos instancia = null;
private Vector dato = new Vector();
private Datos() {
}
public static Datos getInstancia() {
if (instancia == null) {
instancia = new Datos();
}
return instancia;
}
public Vector getDato() {
return dato;
}
public void setDato(Vector dato) {
this.dato = dato;
}
}
--
El contenido de este correo es confidencial y puede ser objeto de acciones
legales. Es dirigido solo para el o los destinatarios(s) nombrados
anteriormente. Si no es mencionado como destinatario, no debe leer, copiar,
revelar, reenviar o utilizar el contenido de este mensaje. Si ha recibido
este correo por error, por favor notifique al remitente y proceda a borrar
el mensaje y archivos adjuntos sin conservar copias.
The information contained in this e-mail is confidential and may also be
subject to legal privilege. It is intended only for the recipient(s) named
above. If you are not named as a recipient, you must not read, copy,
disclose, forward or otherwise use the information contained in this email.
If you have received this e-mail in error, please notify the sender
immediately by reply e-mail and delete the message and any attachments
without retaining any copies.
--
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/478b4fd9-7cfb-49ca-9f69-87326f6ddb79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.