Codenameone HTML和webbrowser

Codenameone HTML和webbrowser,codenameone,Codenameone,我试图在我的代码中使用html页面,因为我从kichensink应用程序中找到了方法,我使用相同的代码和相同的page.html文件应用程序在模拟器上工作,但在设备上不工作。我有一个空白屏幕。下面是我的代码。请帮我做这个 void ShowForm() { Form f = new Form("testweb"); Container cnt = new Container(new BorderLayout()); cnt = createDemo(); f.se

我试图在我的代码中使用html页面,因为我从kichensink应用程序中找到了方法,我使用相同的代码和相同的page.html文件应用程序在模拟器上工作,但在设备上不工作。我有一个空白屏幕。下面是我的代码。请帮我做这个

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,但现在在设备上出现错误,错误是:“网页不可用”page.html未找到。然而,page.html已经放在src中,模拟器上的.res文件和应用程序运行良好

问候,,
Jeny

您不能使边框布局可滚动,包括嵌套滚动和同步滚动native+Codename One小部件可能不是一个好主意


您在哪个设备上遇到问题?Android上的浏览器组件在某些用例中出现了问题,现已修复。

实际上它显示“cnt.addComponent(BorderLayout.NORTH,NORTH);”到目前为止,但当我们添加web浏览器(“cnt.addComponent(BorderLayout.center,wb);”)时,它显示的是“cnt.addComponent(BorderLayout.NORTH,NORTH);”),而这部分不会出现在屏幕上,只是显示一条白线。嗨,阿尔蒙,我正在为我的android设备使用android构建(三星GT-I5801)。请让我知道如何修复此问题,因为它给了我一个找不到page.htm的错误。您的URL中似乎有一个小写的p。请检查文件名的大小写。