I am trying to load a Wikipedia link in a webview which lays inside a fragment.
A sample site site is; http://en.m.wikipedia.org/wiki/Spanish_dollar
If I load it on my mobile browser or even on my desktop, I get the full mobile version with all sections collapsed. However, If I load it in a webview inside a fragment, it does not show the correct “full” mobile wikipedia website. All sections come expanded and the bottom of the site looks different. Also, the menu button on the left side takes up my whole webview, whereas in a normal browser, it takes up 60-70% or less, so you can click the remaining side to go back!
I am dynamically adding the web view into a linear layout inside a fragment like so;
WebView mWebview = new WebView(mContext);
mWebview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mWebview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(mContext, description, Toast.LENGTH_SHORT).show();}
});
mWebview.loadUrl("http://en.m.wikipedia.org/wiki/Spanish_Dollar");
layout.addView(mWebview);
Any help or hints would greatly appreciated, thank you!
This is probably because JavaScript is disabled by default. You can enable it by calling
WebSettings.setJavaScriptEnabled(boolean).