1

我有两个类,一个名为Main另一个是Results

(a) Main 类屏幕有 2 个字段:
1- EditField
2- ButtonField


(b) 结果类:在这个类中有url连接

我希望一旦我单击 ButtonField,它会使用我在 EditField 中输入的数据转到另一个屏幕,以根据我的提交文本解析 xml

像这样 :

http://www.test.com/search.php?q=[ i want the text in the EditField to be here ]

拜托我已经尝试了 2 周
我在 BlackBerry 开发方面非常新

4

1 回答 1

1

好的,您可以使一个具有参数的构造函数是Result类的 String 类型。像这样EditField从您的类中获取按钮单击中的字符串Main

Strnig urlString = youreditfield.getText();//this will be in fieldChanged or any method
 you have used for pushing the Screen

并将这个字符串传递给你从按钮点击推动的那个类,就像这样

UiApplication.getUiApplication().pushScreen(new Result(urlString));

你的类构造函数将是

Result(String yourEditfieldurl) {

   Assign this url to a variable and use it in Result class that's it 

}

或者你可以做一个Static variable

像这样在主类中做一个像这样的变量

public static String editFieldUrl;

在 ButtonField 点击方法中赋值 editFieldUrl = yourEditfield.getText();

并在其他类中使用此变量。我想这可能会对你有所帮助。

于 2012-03-20T03:24:13.923 回答