![]() |
| This is a discussion on How to Update value from current to previous Screen within the IT & Business Professionals forums, part of the Technical Discussions category; Please help me out....... Ok Please take a look: and assist. public class ScreenA extends MainScreen { public static String ... |
| |
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| How to Update value from current to previous Screen
Please help me out....... Ok Please take a look: and assist. public class ScreenA extends MainScreen { public static String Name=null; public ScreenA() { super(NO_VERTICAL_SCROLL); LabelField title = new LabelField("ScreenA", LabelField.USE_ALL_WIDTH); setTitle(title); try { Font fnt = this.getFont().derive(Font.PLAIN, 10); LabelField t = new LabelField("Hi There",LabelField.HCENTER | LabelField.FIELD_HCENTER | LabelField.USE_ALL_WIDTH) { public void paint(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0,0,this.getWidth(),this.getHeight()); g.setColor(Color.WHITE); super.paint(g); }}; t.setFont(fnt); add(t); } catch (Exception e) { Dialog.alert("Error: "+e); } /****************** Code for inserting Image *********************/ Refresh(); . addMenuItem(ScreenB); } public void Refresh() { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { try { System.out.println("Got it .............."+Name); if (Name != null) { LabelField titlee = new LabelField(Name,LabelField.HCENTER | LabelField.FIELD_HCENTER| LabelField.USE_ALL_WIDTH | LabelField.USE_ALL_HEIGHT) { public void paint(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0,0,this.getWidth(),this.getHeight()); g.setColor(Color.WHITE); super.paint(g); }}; Font fnt = this.getFont().derive(Font.PLAIN, 8); titlee.setFont(fnt); add(titlee); System.out.println("@454545454....."+titlee.toStri ng()); } else System.out.println("Name field is null"); } catch (Exception e) { Dialog.alert("Error: "+e); } invalidate(); }}); } } ///////////////////////////////// ScreenB 2nd Screeeeeeeeeeeeeeeeeennnnnnnnnn////////////// public class ScreenB extends MainScreen { public ScreenB() { LabelField title = new LabelField("ScreenB", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); setTitle(title); EditField dig = new EditField("Please enter Your Name ", "", 32, EditField.FILTER_DEFAULT); add(dig); ButtonField btnS = new ButtonField("Next", ButtonField.FIELD_LEFT|ButtonField.CONSUME_CLICK); add(btnS); btnS.setChangeListener(new ButtonListener()); } public class ButtonListener implements FieldChangeListener { public void fieldChanged(Field field, int context) { ButtonField btn = (ButtonField)field; try { Name = dig.toString(); if (btn.getLabel() == "Next") SendMessage(); /// Sending message on this action } catch (Exception e) { Dialog.alert("Error: "+e); } } } public void close() { // pushScreen(new ScreenA()); ScreenA sc = (ScreenA) UiApplication.getUiApplication().getActiveScreen() .getScreenBelow(); sc.Refresh(); UiApplication.getUiApplication().popScreen(this); } } Please assist whether this code is correct or not. Here when I m calling sc.Refresh(); from close() of ScreenB Its get in to the condition if (Name != null) on ScreenA and print System.out.println("@454545454....."+titlee.toStri ng()); but while updating to Screen add(titlee); Its showing : WARNING: Cannot layout field, insufficient height Please Assist.... First Please check the code Is it correct or not. I want to update Name Enter in Screen B to previous ScreenA which is in the Stack. Please give example How to do this ...... I just got stuck in this!!!!!!!!!!!!!!!!!!!!! If I use pushScreen(); then it will works fine..............But! again Memory and Stack Issue. Please waiting for Replies.... |