您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。