android webview 显示空白页问题解决

来源:互联网 发布:免费网站源码怎么安装 编辑:程序博客网 时间:2024/05/22 07:51
原来的代码如下所示,但是一直展示空白页面。
private WebView webView ;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main_webview);this.webView=(WebView) this.findViewById(R.id.WebView);this.webView.getSettings().setSupportZoom(false);//this.webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);this.webView.getSettings().setJavaScriptEnabled(true);this.webView.getSettings().setDomStorageEnabled(true);//this.webView.loadUrl("http://weibo.cn/");webView.setWebViewClient(new WebViewClient(){           public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){                     //handler.cancel(); 默认的处理方式,WebView变成空白页   //                  //接受证书           handler.proceed();                 //handleMessage(Message msg); 其他处理          } });this.webView.loadUrl("http://*.*.*.*:8080/html/hello.html");}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context=".MainActivity" >   <WebView android:id="@+id/WebView"        android:layout_width="fill_parent"         android:layout_height="0dip"/></RelativeLayout>



修改方式:

<?xml version="1.0" encoding="UTF-8"?><AbsoluteLayout android:orientation="vertical" android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent"  xmlns:android="http://schemas.android.com/apk/res/android">    <WebView android:id="@+id/WebView"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:layout_x="0.0dip"    android:layout_y="0.0dip"    android:layout_weight="1.0" /></AbsoluteLayout>




原创粉丝点击