atmenezes
atmenezes

Reputation: 43

Web browser showing as a line in device

I tried to add the web-browser in code:

@Override
    protected void beforeMain(Form f) {

        final Container cont = new Container(new BorderLayout());
        String url = "https://www.google.com";

        WebBrowser web = new WebBrowser() {

            @Override
            public void onLoad(String url) {

                this.setShouldCalcPreferredSize(true);

                Display.getInstance().callSerially(new Runnable() {

                    public void run() {

                        cont.revalidate();

                    }
                });
            }

        };

        web.setURL(url);
        cont.addComponent(BorderLayout.CENTER, web);
        cont.revalidate();
        f.addComponent(cont);
}

In the simulator works fine but in Android device is showing one-pixel line...why?

thanks

Upvotes: 1

Views: 29

Answers (1)

Diamond
Diamond

Reputation: 7483

The problem is because your form layout is a FlowLayout. Change your form Layout to BorderLayout and add the browser container to the center

@Override
protected void beforeMain(Form f) {

    final Container cont = new Container(new BorderLayout());
    String url = "https://www.google.com";

    WebBrowser web = new WebBrowser() {

        @Override
        public void onLoad(String url) {

            this.setShouldCalcPreferredSize(true);

            Display.getInstance().callSerially(new Runnable() {

                public void run() {

                    cont.revalidate();

                }
            });
        }

    };

    web.setURL(url);
    cont.addComponent(BorderLayout.CENTER, web);
    f.setLayout(new BorderLayout());
    f.addComponent(BorderLayout.CENTER, cont);
    f.revalidate();
}

Upvotes: 2

Related Questions