public class MainActivity extends Activity { private Button btn; private Button btn2; private WebView web; private Button btn3; private Button btn4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn = (Button) findViewById(R.id.button1); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent=new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.baidu.com")); startActivity(intent); } }); btn2 = (Button) findViewById(R.id.button2); web = (WebView) findViewById(R.id.webview); btn2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub web.loadUrl("http://172.27.0.200/exam/"); } }); btn3 = (Button) findViewById(R.id.button3); btn3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub web.loadData("<html><body>fdsfgsdgdsf</body></html>", "text/html", "utf-8"); } }); btn4 = (Button) findViewById(R.id.button4); btn4.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub WebSettings setting =web.getSettings(); setting.setDefaultTextEncodingName("utf-8"); setting.setJavaScriptCanOpenWindowsAutomatically(true); setting.setJavaScriptEnabled(true); web.setWebChromeClient(new WebChromeClient()); web.loadUrl("file:///android_asset/jsdemo.html"); } }); } }