WebView
Role:
A Web page can be displayed as a view (essentially a Web page) on the phone's client side.
Mainactivity code "Instance resolution"
Package Com.example.webview;import Android.os.bundle;import Android.app.activity;import android.view.KeyEvent; Import Android.view.menu;import Android.view.window;import Android.webkit.webview;import Android.webkit.webviewclient;public class Mainactivity extends Activity {private WebView WebView; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Requestwindowfeature (window.feature_ No_title); Setcontentview (r.layout.activity_main); WebView = (WebView) This.findviewbyid (R.id.webview); Webview.getsettings (). Setjavascriptenabled (true);//is support for JavaScript language Webview.loadurl ("https://www.baidu.com/"); Webview.setwebviewclient (New Mywebviewclient ());} /* * Remove the progress bar and URL from the Web page shown in WebView to make it more like a customer service application * * */class Mywebviewclient extends webviewclient{@Overridepublic boolean Shouldov Errideurlloading (WebView view, String URL) {view.loadurl (URL); return true;}} /** * Make the Click rewind button not exit the entire application directly but return to the previous page * */@Overridepublic boolean onKeyDown (int keycode, keyevent event) {if (keycode= = Keyevent.keycode_back&&webview.cangoback ()) {webview.goback ();//Return to last page return true;} Return Super.onkeydown (KeyCode, event);//exit the entire application}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
WebView "Instance resolution" for Android network programming