本文介绍了如何在黑莓中将字符串值从一个屏幕发送到另一个屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都请帮我将字符串值从一个屏幕传递到黑莓中的另一个屏幕
Anyone please help me to pass String value from one screen to another screen in Blackberry
推荐答案
我想说的是从第一个屏幕推送第二个屏幕,而不是从应用程序中推送.
应用内推送第一屏:
I would say to do pushing 2nd screen from the 1st screen, not from the application.
In app push first screen:
public class App extends UiApplication {
public static void main(String[] args) {
App app = new App();
app.enterEventDispatcher();
}
public App() {
FirstScreen scr = new FirstScreen();
pushScreen(scr);
}
}
第二个屏幕有一个字符串值的设置器:
Second screen has a setter for string value:
public class SecondScreen extends MainScreen {
String mTextValue = null;
LabelField mLabel = null;
public void setTextValue(String textValue) {
mTextValue = textValue;
mLabel.setText(mTextValue);
}
public SecondScreen() {
super();
mLabel = new LabelField();
add(mLabel);
}
}
在第一个屏幕中创建第二个,设置字符串值并推送它.如果您不需要返回,则弹出第一个屏幕:
In first screen create second, set string value and push it. Pop first screen if you don't need to return on it:
public class FirstScreen extends MainScreen implements FieldChangeListener {
BasicEditField mEdit = null;
ButtonField mButton = null;
public FirstScreen() {
super();
mEdit = new BasicEditField("input: ", "some text");
add(mEdit);
mButton = new ButtonField("Go second screen");
mButton.setChangeListener(this);
add(mButton);
}
public void fieldChanged(Field field, int context) {
if(mButton == field)
{
SecondScreen scr = new SecondScreen();
scr.setTextValue(mEdit.getText());
UiApplication.getUiApplication().pushScreen(scr);
UiApplication.getUiApplication().popScreen(this);
}
}
}
这篇关于如何在黑莓中将字符串值从一个屏幕发送到另一个屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!