[Android] WebView custom browser
Add < EditText / > and < button / > controls to the layout file,
Add a < WebView / > control to the layout file
Get WebView object in activity
Call the loadurl() method of WebView object, parameter: string path
Add permission to access the network android.permission.internet
Call the getsettings () method of the WebView object to get the websettings setting object
Call the setsupportzoom() method of the websettings object to set the support zoom. Parameter: Boolean
Call setbuiltinzoomcontrols() of websettings object to set the zoom control. Parameters: Boolean
Call the setwebviewclient() method of WebView object to set the client to prevent the link from opening the system browser. Parameter: webviewclient object
Monitor the back key to return to the previous interface
Override the onkeydown () method of the activity, and pass in the int keyboard code and keyevent object as parameters
If the keyboard code is equal to keyevent.keycode_ Back and there are many pages in the current WebView object that can go back. Call the cangoback () method of the WebView object
Call the goback () method of WebView object, and the page goes back
Set the menu key, override the oncreateoptionsmenu() method, and pass in the menu object
Call the addsubmenu() method of the menu object to add the menu. Parameters: group ID, item ID, sorting, title
Add refresh, back, forward
Listen for small menu click events
Override the onoptionsitemselected () method and pass in the MenuItem object
Switch judge the getorder () of the MenuItem object, which corresponds to the above sort
Page refresh, call the reload () method of WebView object
When the page goes back, first call the cangoback () method of WebView object to judge whether it can go back, and call the goback () method to go back
When the page advances, call the cangoforward () method of WebView object to judge whether it can advance, and call the goforward () method to advance
Page loading
Get the ProgressDialog object and new it. Parameter: Context
Call the setmessage() method of the ProgressDialog object, parameter: Text
Call setwebchromeclient() method of WebView object. Parameters: webviewclient object,
The anonymous inner class inherits the webviewclient class and overrides the onpagestarted () method and onpagefound () method
Within the onpagestarted() method
Call the show() method of the ProgressDialog object
Within the onpagefound() method
Call the disass() method of the ProgressDialog object