Code example for WebView

Methods: layoutgetSettingsloadDataWithBaseURLsetWebViewClient

0
     legendLayoutparams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
     legendLayoutparams.setMargins(15, 15, 0, 0);
     legendLayout.setLayoutParams(legendLayoutparams);
      
     // now create the webview itself, and add to legendView 
     WebView webView = new WebView(activity);
     webView.getSettings().setJavaScriptEnabled(true);
     // force to open any URLs in native browser instead of WebView  
     webView.setWebViewClient(new WebViewClient() {
           @Override 
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
              return super.shouldOverrideUrlLoading(view, url);
           } 
       }); 
     webView.layout(0, 0, 320, 300);
     webView.loadDataWithBaseURL("file:///android_asset/",HTML_HEAD+html+HTML_FOOT, "text/html", "UTF-8",null);
     legendLayout.addView(webView);
      
     mainLayout.addView(legendLayout);
 } 
}