import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.Window; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; public class chengji extends Activity { private WebView wv; private ProgressBar progressBar; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.webview); progressBar = (ProgressBar) findViewById(R.id.pro); wv = (WebView) findViewById(R.id.webview); wv.getSettings().setAllowFileAccess(true); wv.getSettings().setJavaScriptEnabled(true); wv.loadUrl("http://www.gdousu.com/wap/tools/grade.aspx"); wv.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (wv.getContentHeight() != 0) { } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); wv.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 0) { progressBar.setVisibility(View.VISIBLE); } progressBar.setProgress(newProgress); progressBar.postInvalidate(); if (newProgress == 100) { progressBar.setVisibility(View.GONE); } } }); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && wv.canGoBack()) { wv.goBack(); return true; } else return super.onKeyDown(keyCode, event); } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。