
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 0.80 KB | hits: 37 | expires: Never
WebView with shouldOverrideUrlLoading and baseURL
WebView wv = (WebView) findViewById(R.id.EditorialWebView);
wv.setBackgroundColor(0x00000000);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadDataWithBaseURL("", editorialBoard, "text/html", "utf-8", "");
wv.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView wv, String url) {
if (url.startsWith("/"))
{
wv.loadUrl("http://www.mdpi.com"+url);
}
return true;
}
});
myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("/")) {
Uri u = Uri.fromParts("http://www.domain.com", url, "");
view.loadUrl(u);
}
return true;
}
});