Webview loaded outside the screen?
source link: https://www.codesd.com/item/webview-loaded-outside-the-screen.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Webview loaded outside the screen?
This code was working with another aspx form, now when I changed the form, it works in blackberry's webview however the android now boots a external browser, even know before it booted within the application.
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.setInitialScale (5);
webview.loadUrl(URL);
webview.requestFocus(View.FOCUS_DOWN);
why is it loading outside the browser now?
All you need is to implement shouldOverrideUrlLoading()
. A snippet from my recent project:
public class WebViewCustom extends Activity {
WebView mWebView;
String mUrl;
String urlHistory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lessons_page);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setWebViewClient(new WebViewOverrideUrl());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("YOUR-URL-HERE");
}
private class WebViewOverrideUrl extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Happy coding!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK