Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. WebView with shouldOverrideUrlLoading and baseURL
  2. WebView wv = (WebView) findViewById(R.id.EditorialWebView);
  3. wv.setBackgroundColor(0x00000000);
  4. wv.getSettings().setJavaScriptEnabled(true);
  5. wv.loadDataWithBaseURL("", editorialBoard, "text/html", "utf-8", "");
  6. wv.setWebViewClient(new WebViewClient()
  7.     {
  8. @Override
  9. public boolean shouldOverrideUrlLoading(WebView wv, String url) {
  10. if (url.startsWith("/"))
  11.     {
  12. wv.loadUrl("http://www.mdpi.com"+url);
  13. }  
  14. return true;
  15. }                      
  16. });
  17.        
  18. myWebView = (WebView) findViewById(R.id.webview);
  19. myWebView.setWebViewClient(new WebViewClient() {
  20.   public boolean shouldOverrideUrlLoading(WebView view, String url) {
  21.     if(url.startsWith("/")) {
  22.       Uri u = Uri.fromParts("http://www.domain.com", url, "");
  23.       view.loadUrl(u);
  24.     }
  25.     return true;
  26.   }
  27. });