Skip to main content

Using Android WebView instead of HTMLComponent

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2009-11-03


In my android app I wish to use the native Android WebView instead of LWUIT HTMLComponent, mainly because WebView allows to embedd a youtube video.
I'm using LWUIT 1.5 with the latest (SVN) thorsten's port.
I tried to use a PeerComponent with a WebView inside adding the peer component to my form but the webview isn't shown in the form.
This is my snippet:

setLayout(new BorderLayout());
boolean looperNeeded = Looper.myLooper() == null;      

WebView webView = new WebView(activity);

Component component = PeerComponent.create(webView);          
component.setPreferredH((int)(Display.getInstance().getDisplayHeight() * activity.getResources().getDisplayMetrics().density + 0.5f));
component.setPreferredW((int)(Display.getInstance().getDisplayWidth() * activity.getResources().getDisplayMetrics().density + 0.5f));
webView.loadData(data, "text/html", "utf-8");

addComponent(BorderLayout.CENTER, component);

How can I show the native WebView in LWUIT form?

Ugo Chirico

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-11-03

I solved running this code in the Android UI Thread using:

activity.runOnUiThread(new Runnable() {
            public void run() {
                webView = new WebView(activity);