Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As Vijay, suggested this is one way that we could achieve this using inner class. The other approach could be, using design observer design patterns.</p> <p>Try understanding the below code, and use what ever is efficient for you. </p> <p><strong>MyScreen.java</strong></p> <pre><code>public class MyScreen extends MainScreen implements MyListener { MyScreen screen = null; public MyScreen() { screen = this; LabelField lblField = new LabelField(); lblField.setText("Current Value = " + currentValue); ButtonField btnPopup = new ButtonField("Show Popup"); btnPopup.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().pushScreen(new MyPopupScreen(screen)); } }); add(lblField); add(btnPopup); } public void valueChanged(int selectedIdx) { Dialog.alert(selectedIdx ); } } </code></pre> <p><strong>MyListener.java</strong></p> <pre><code>public interface MyListener { public void valueChanged(int selectedIdx); } </code></pre> <p><strong>MyPopupScreen.java</strong></p> <pre><code>public class MyPopupScreen extends PopupScreen implements FieldChangeListener { MyScreen deligate = null; public MyPopupScreen(final MyScreen deligate) { super(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL|VerticalFieldManager.VERTICAL_SCROLLBAR), Field.FOCUSABLE); this.deligate = deligate; add(new LabelField("Select Type")); ButtonField closeBtn = new ButtonField("Close"); ButtonField okBtn = new ButtonField("OK"); add(okBtn); add(closeBtn); closeBtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); } }); okBtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { deligate.valueChanged(radioGroup.getSelectedIndex()); UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); } }); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload