webView. SetWebViewClient (new WebViewClient () {
//links jump will go this way
@ Override
Public Boolean shouldOverrideUrlLoading (WebView view, String url) {
Intent Intent=new Intent (MainActivity. This, secondWebViewActivity. Class);
Intent. PutExtra (" url ", url);
startActivity(intent);
The v (" sas ", "* * * * * * *");
return true;
Executed in the end, return true black to drop flash back, secondWebViewActivity has been registered, where is write wrong?
MainActivity complete code
Public class MainActivity extends the Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
//hide the titlebar of application
//must be before setting the layout
RequestWindowFeature (Window. FEATURE_NO_TITLE);
//hide the statusbar of Android
//could also be done later
(WindowManager getWindow (). SetFlags. LayoutParams. FLAG_FULLSCREEN,
WindowManager. LayoutParams. FLAG_FULLSCREEN);
The setContentView (R.l ayout. Activity_main);
Final WebView WebView=(WebView) the findViewById (R.i d.x gz_webview);
WebView. SetOnKeyListener (new View. OnKeyListener () {
@ Override
Public Boolean onKey (View v, int keyCode, KeyEvent event) {
If (event. GetAction ()==KeyEvent. ACTION_DOWN) {
//can press the return key operation and back page
If (keyCode==KeyEvent. KEYCODE_BACK & amp; & WebView. CanGoBack ()) {
//back
WebView. GoBack ();
return true;
}
}
return false;
}
});
//if I can back
WebView. CanGoBack ();
//set the WebView attributes, can perform Javascript
WebView. GetSettings (.) setJavaScriptEnabled (true);
//load the web link
WebView. LoadUrl (" http://haxgzdjfw.cn/m/index.html ");
WebView. SetWebViewClient (new WebViewClient () {
//links jump will go this way
@ Override
Public Boolean shouldOverrideUrlLoading (WebView view, String url) {
Intent Intent=new Intent (MainActivity. This, secondWebViewActivity. Class);
Intent. PutExtra (" url ", url);
startActivity(intent);
The v (" sas ", "* * * * * * *");
return true;
}
});
}
}
CodePudding user response:
Log,,,,,,,CodePudding user response: