1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| WebView webView; TextView tip;
tip= (TextView) findViewById(R.id.tip); webView= (WebView) findViewById(R.id.web_view); WebSettings webSettings=webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false);
webView.setWebViewClient(new WebViewClient()); webView.loadUrl("https://www.baidu.com");
webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { tip.setText("网页加载完成"); tip.setVisibility(View.GONE); } else { tip.setText("正在加载..."+newProgress+"%"); } } });
|