Add Network permissions in Androidmanifest.xml
<uses-permission android:name= "Android.permission.INTERNET"/>
Activity_main.xml
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "    android:orientation= "vertical"    tools:context= ". Mainactivity ">    <button        android:id=" @+id/main_button "        android:layout_width=" Match_parent "        android:layout_height= "wrap_content"        android:text= "Start"/>    <webview        android:id= "@+id /main_web "        android:layout_width=" match_parent "        android:layout_height=" Match_parent "/></ Linearlayout>
Mainactivity.java
Package Com.example.webviewdemo01;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.util.log;import Android.view.view;import Android.view.View.OnClickListener; Import Android.webkit.webchromeclient;import Android.webkit.webview;import Android.webkit.webviewclient;import Android.widget.button;public class Mainactivity extends Activity implements Onclicklistener {private Button Main_button ;p rivate WebView web_view; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.activity_main);//Initialize Data Initview ();} private void Initview () {//TODO auto-generated method Stubmain_button = (Button) This.findviewbyid (R.id.main_button); Web_view = (WebView) This.findviewbyid (r.id.main_web);//Set Listener Main_button.setonclicklistener (this);} @Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubweb_view.loadurl ("http://www.baidu.com");// Webchromeclienty dialog box for handling WebView JavaScript,//Website icon, site title, loading progress, etc., rewrite the method can be web_view.setwebchromeclient (new webchromeclient ());//This method is not written here// Webviewclient used to handle webview various notifications, request events, etc., rewrite the method can be web_view.setwebviewclient (new Webviewclient () {// Clicking on a link in the page will call this method @overridepublic Boolean shouldoverrideurlloading (WebView view, String URL) {//TODO auto-generated Method stub//jumps to another activityintent intent = new Intent (Getapplication (), secondactivity.class); startactivity (intent); LOG.I ("Qing", "shouldoverrideurlloading ..." + URL); return super.shouldoverrideurlloading (view, URL);}});}}Run:
Click on any one of the links above
Note: The code and layout of the second activity is not posted because there is not much content written.
Nineth Chapter, WebView click on the link in the page to jump to other activity (Android)