2012-01-02 99 views

回答

3

通过构造函数,你可以从一个屏幕另一个屏幕传递值

例如 当你点击ButtonField字段可以FieldChanged方法

 int i=10; 
     UiApplication.getUiApplication().pushScreen(new Sample(i)); 

内的样品类中写这个你必须做出一个构造函数,你必须像下面这样

public class sample extends MainScreen{ 
private int i=0; 
    public sample(int i) { 
     this.i=i;// now you can get i value which was you pass from before screen 

    } 
} 

其他的方法是使该值为静态,如果你想从一些值使用使用previousScreenname.variableName

1

下一个屏幕上你的价值,你current screen to the other screen可以看到堆栈溢出这个问题how-to-send-string-value-from-one-screen-to-another-in-blackberry也可以使屏幕的构造的其他方式具有所需类型的参数并使用当前屏幕上显示的值推送displaystack上的屏幕。还有另外一种方法是在另一个屏幕static上创建你想要的值,并在下一个屏幕上使用该值,使用YourPrevScreen.thatVariablename,你声明为静态的

相关问题