可能重复:
How to send String value from one screen to another in Blackberry? 黑莓手机如何将一个屏幕传递给另一个屏幕?
如何从一个屏幕传递值(如String,int)以在黑莓另一屏幕。 请帮助我。 在此先感谢。
可能重复:
How to send String value from one screen to another in Blackberry? 黑莓手机如何将一个屏幕传递给另一个屏幕?
如何从一个屏幕传递值(如String,int)以在黑莓另一屏幕。 请帮助我。 在此先感谢。
通过构造函数,你可以从一个屏幕另一个屏幕传递值
例如 当你点击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
下一个屏幕上你的价值,你current screen to the other screen
可以看到堆栈溢出这个问题how-to-send-string-value-from-one-screen-to-another-in-blackberry也可以使屏幕的构造的其他方式具有所需类型的参数并使用当前屏幕上显示的值推送displaystack上的屏幕。还有另外一种方法是在另一个屏幕static
上创建你想要的值,并在下一个屏幕上使用该值,使用YourPrevScreen.thatVariablename
,你声明为静态的