我尝试在我的代码中使用html页面,我从kichensink应用程序找到了方法,我使用相同的代码和相同的page.html文件应用程序在模拟器上工作但不在设备上工作。 Ondevices我有一个空白的屏幕。以下是我的代码。请帮帮我。
void ShowForm()
{
Form f = new Form("testweb");
Container cnt = new Container(new BorderLayout());
cnt = createDemo();
f.setLayout(new BorderLayout());
f.addComponent(BorderLayout.CENTER, cnt);
f.show();
}
public Container createDemo() {
Container cnt = new Container(new BorderLayout());
final WebBrowser wb = new WebBrowser();
if(wb.getInternal() instanceof BrowserComponent) {
Button btn = new Button("Add");
final TextArea content = new TextArea();
Container north = new Container(new BorderLayout());
north.addComponent(BorderLayout.CENTER, content);
north.addComponent(BorderLayout.EAST, btn);
cnt.addComponent(BorderLayout.NORTH, north);
content.setHint("Add to web document");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
((BrowserComponent)wb.getInternal()).execute("fnc('" + content.getText() + "');");
}
});
((BrowserComponent)wb.getInternal()).setBrowserNavigationCallback(new BrowserNavigationCallback() {
public boolean shouldNavigate(String url) {
if(url.startsWith("http://sayhello")) {
// warning!!! This is not on the EDT and this method MUST return immediately!
Display.getInstance().callSerially(new Runnable() {
public void run() {
((BrowserComponent)wb.getInternal()).execute("fnc('this was written by Java code!');");
}
});
return false;
}
return true;
}
});
}
cnt.addComponent(BorderLayout.CENTER, wb);
wb.setURL("jar:///page.html");
return cnt;
}
嗨,我为容器做了很少的更改setlayout并添加到另一个cotainer,其中可滚动的true为容器,可滚动的false为表单,但现在它在设备上给我错误,错误是:“web page not available”page.html not found 。而page.html已经放在src中,并且.res文件和模拟器上的应用程序正常工作。
此致 耶尼
答案 0 :(得分:0)
你不能使边框布局可滚动,包括嵌套的可滚动和滚动原生+ Codename同步的一个小部件可能不是一个好主意。
您遇到问题的是哪种设备?对于某些用例,Android上的浏览器组件存在问题,现在已修复。