沒幣了,來個好心人。打開一個app如何直接進入網頁,而不用輸入網址(使用loadUrl),像UC手機浏覽器一樣
剛好在做的項目有點也用到,參考下:
load = (TextView)findViewById(R.id.web_loading_text);
pb = (ProgressBar)findViewById(R.id.web_progressBar1);
wv = (WebView)findViewById(R.id.mysign_web);
WebSettings settings = wv.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);//設定支持viewport
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setSupportZoom(true);//設定支持縮放
if(URL == null)
URL = "http://www.baidu.com";
wv.loadUrl(URL);
wv.setWebViewClient(new WebViewClient(){
@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) {
// TODO Auto-generated method stub
if (newProgress == 100) {
// 網頁加載完成
load.setVisibility(View.GONE);
pb.setVisibility(View.GONE);
} else {
// 加載中
}
}
});