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.
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();
}
}