wv = (WebView) findViewById(R.id.webView1);
wv.getSettings().setJavaScriptEnabled(true);
wv.setScrollBarStyle(0);
WebSettings webSettings = wv.getSettings();
webSettings.setAllowFileAccess(true);
webSettings.setBuiltInZoomControls(true);
wv.loadUrl("http://www.baidu.com");
//加載數(shù)據(jù)
wv.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress)
{
if (newProgress == 100) {
MainActivity.this.setTitle("加載完成");
} else {
MainActivity.this.setTitle("加載中.......");
}
}
});
//這個(gè)是當(dāng)網(wǎng)頁上的連接被點(diǎn)擊的時(shí)候
wv.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading
final String url) {
loadurl(view, url);
return true;
}
});
public boolean onKeyDown(int keyCoder, KeyEvent event) {
if (wv.canGoBack() && keyCoder
== KeyEvent.KEYCODE_BACK) {
wv.goBack();
return true;
}
return false;
}
二.不然你就調(diào)用android內(nèi)置安裝的瀏覽器來打開網(wǎng)頁.
|
|