1 package com.example.main;
2
3
4 import android.app.Activity;
5 import android.os.Bundle;
6 import android.webkit.WebView;
7 import android.webkit.WebViewClient;
8
9 public class MainActivity2 extends Activity {
10
11 private WebView webView;
12
13
14 @Override
15 protected void onCreate(Bundle savedInstanceState) {
16 super.onCreate(savedInstanceState);
17 setContentView(R.layout.activity_main2);
18
19 webView = (WebView) findViewById(R.id.webView);
20
21 //支持javascript
22 webView.getSettings().setJavaScriptEnabled(true);
23
24 //在webview内部跳转web页面
25 webView.setWebViewClient(new WebViewClient(){
26 @Override
27 public boolean shouldOverrideUrlLoading(WebView view, String url) {
28 view.loadUrl(url);
29 return true;
30 }
31 });
32
33 //加载web页面
34 webView.loadUrl("http://192.168.0.196/test/");
35
36 }
37 }