After the previous article, we can already open the HTML page, but there are many details of the content we need to adjust.
Careful netizen may have found, open Baidu page, click the link at the top, will open the corresponding page in the browser of the phone, this is obviously not what we want.
Add the following code in the OnCreate
Webview.setwebviewclient (New Webviewclient ()
{
public boolean shouldoverrideurlloading (WebView view,string URL)
{
View.loadurl (URL);
return true;
}
});
You can open the link on the current page.
The problem of opening the link is resolved, but after the link is opened, click the Back button to exit the program directly.
Overloads the onkeydown function so that it is rolled back within the page
@Override
@Override
public boolean onKeyDown (int keycoder,keyevent event)
{
In-page fallback
if ((keycoder==keyevent.keycode_back) && webview.cangoback ()) {
Webview.goback ();
return true;
}
Return Super.onkeydown (keycoder,event);
}
Questions that pop up in the prompt box
Add a button to the index page, alert pop-up prompt
<button onclick= "alert (' Test popup ')" > Pop-up Window </button>
Teach you to create your first Android app with Android Studio load HTML5 page (ii)