In the development of often inexplicable problems, make a record, convenient to summarize later, the series will not be updated regularly!
WebView is a component of Android and its kernel is based on the open source WebKit engine. If we do some beautification and packaging of the webview, we can develop our own browser very easily.
1, prohibit hyperlinks when the call to other browsers
Today invoke Web page display control, a set of carousel diagram, according to the server returned by the URL to do the Web page display, the same format, some can normally open in WebView, some will be inexplicably pop up the browser selection box. Very depressed!
Search a bit, find the solution, two steps, as follows:
Step1: First, the page control initialization section
String URL = getintent (). Getstringextra ("url"); WebView WebView = (WebView) Findviewbyid (R.id.webview); Webview.loadurl (URL);//If you want to click on the link to handle it yourself, Instead of the new Android system browser should be linked in the ring. You need to add an Event listener object (webviewclient) to WebView and override the Shouldoverrideurlloading method Webview.setwebviewclient (New Mywebviewclient ());
Step2: Adding a Listener object
Private class Mywebviewclient extends Webviewclient {public Boolean shouldoverrideurlloading (WebView view, String URL) {V Iew.loadurl (URL); return true;};}
2. Scroll bar Settings
Webview.sethorizontalscrollbarenabled (TRUE);//Set the horizontal scrollbar, true to allow the use of webview.setverticalscrollbarenabled (false);// Sets the vertical scroll bar , false to prohibit the use of the
3. When the screen switch is forbidden, reload the webpage
Need to add android:configchanges= "Keyboardhidden|orientation|screensize" in Androidmanifest.xml
4. Turn on JavaScript support
Webview.getsettings (). Setjavascriptenabled (true);//Turn on JavaScript support
5. settings can automatically load pictures
Webview.getsettings (). Setloadsimagesautomatically (true);//settings can automatically load pictures
Android Base controls use details--webview