WebView webview = new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);//可用JS
webview.setScrollBarStyle(0);//滚动条风格,为0就是不给滚动条留空间,滚动条覆盖在网页上
//确定这个控件的大小和位置
left = 0;
top = 36*nDisplayHeight/main.nDefaultHeigh;
width = nDisplayWidth;
height = 195*nDisplayHeight/main.nDefaultHeigh;
lpParam = new AbsoluteLayout.LayoutParams(width,height,left,top);
abslayout.addView(webview, lpParam);
webview.setWebViewClient(new WebViewClient()
{
public boolean shouldOverrideUrlLoading(final WebView view, final String url)
{
if(url.endsWith(".avi")||url.endsWith(".mpg")||url.endsWith(".asf")||url.endsWith(".wmv")
||url.endsWith(".mp4")||url.endsWith(".flv")||url.endsWith(".3gp")||url.endsWith(".vob")
||url.endsWith(".mkv")||url.endsWith(".mov")||url.endsWith(".webm")||url.endsWith(".ogv")
||url.endsWith(".mp3")||url.endsWith(".wma")||url.endsWith(".wav")||url.indexOf("rtsp://")!=-1)
{
Intent intent=new Intent("android.intent.action.VIEW",Uri.parse(url));
view.getContext().startActivity(intent);
}
else
{
view.loadUrl(url);
}
return true;
}
});
webview.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view,int progress)
{//载入进度改变而触发
if(progress==100)
{
}
super.onProgressChanged(view, progress);
}
});
webview.loadUrl("http://wap.szicity.com");