I am calling a popupscreen where I have objectchoicefield where I select a data from dropdown and set the value in static variable. I need to read this value in the constructor of the mainscreen from where popupscreen was called.
How to do this ?I want the same screen to be reloaded with the data that I selected now.
Initially when I launch the app I see the Ascreen with some data ,once I click on an image I call a popup screen ,where I select some data ,now I want to reload AScreen with the selected value,once popupscreen is closed.
Ascreen
Public AScreen(){
String timezone_static = MyPopup.ocfDATA;
}
if (field == bitmapField1) {
UiApplication.getUiApplication().pushScreen(new MyPopup(screen));
}
public class MyPopup extends PopupScreen {
ObjectChoiceField ocf;
NativeScreen deligate = null;
public static String ocfDATA;
public MyPopup(final NativeScreen deligate) {
super(new VerticalFieldManager(), Field.FOCUSABLE);
this.deligate = deligate;
// this listener 'listens' for any event (see at the bottom)
FieldListener listener = new FieldListener();
TimeZone[] zone = TimeZoneUtilities.getAvailableTimeZones();
ocf = new ObjectChoiceField("Set Timezone", zone);
ocf.setChangeListener(listener);
add(ocf);
}
class FieldListener implements FieldChangeListener {
public void fieldChanged(Field f, int context) {
if (f == ocf) {
Object ob = ocf.getChoice(ocf.getSelectedIndex());
String str = ob.toString();
ocfDATA = str;
deligate.valueChanged(str);
Dialog.alert(str);
close();
}
}
}
i am explaining some of flow how to navigate from one screen another screen with values.
this is simple way in your main screen
otherwise you want to know more to navigate from one place to another is just understand following code
My suggestion is that if you want to update more design from another class then just separate out the constructor and design
like
all your design write in one method suppose CreateGui(); call this method from constructer;
if you want to reload update design just call CreateGui from onExposed() method