我想将LocalURL的值传递给另一个Screen。我试过这个,但我得到的只是空白屏幕:BlackBerry - how to pass data like Intent.putExtra() in Android
喜欢android:
(在屏幕1中)
WebView webView;
webView = (WebView) findViewById(R.id.webView);
Bundle extras = getIntent().getExtras();
String value = "file:///android_asset/errorpage.html";
if (extras != null) {
value = extras.getString("keyHTML");
}
和(在Screen2中)
Intent i = new Intent(this, Screen1.class);
i.putExtra("keyHTML", "file:///android_asset/page2.html");
startActivity(i);
如何在Blackberry中实现类似的功能,我目前使用:
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(
BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(
myBrowserFieldConfig);
sscreen = new MainScreen();
sscreen.add(browserField);
if (name.equals("Santa Claus")) {
Ui.getUiEngine().pushScreen(sscreen);
browserField.requestContent("local:///santa.html");
} else if (name.equals("Christmas")) {
Ui.getUiEngine().pushScreen(sscreen);
browserField.requestContent("local:///christmas.html");
但是我看到它在显示HTML之前需要一段时间,我想如果我能在android中传递数据,那么它会更快打开。
修改
NewScreen中的
public NewScreen(String url) {
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(myBrowserFieldConfig);
add(browserField);
url = "local:///errorpage.html";
browserField.requestContent(url);
}
OldScreen中的
if (check.equals("1") || check.equals("001")) {
NewScreen newscreen = new NewScreen("local:///page1.html");
UiApplication.getUiApplication().pushScreen(newscreen);
NewScreen被推送但仍显示默认值" url =" local:///errorpage.html" ;;"我认为它应该改为OldScreen中设置的新值" local:///page1.html"什么时候跑。请解释一下。
答案 0 :(得分:1)
试试这个 -
new_screen = new new_screen(your_url);
UiApplication.getUiApplication().pushScreen(new_screen);
在你的new_screen类中 -
public class new_screen extends MainScreen{
public new_screen(String url){
//here you will get the value of url from the variable url.
}
}