Android webview无法加载网页

时间:2017-04-13 11:32:35

标签: android webview

我无法使用webview加载网页,没有显示任何内容, 这个网址“http://dev.51yunche.com:7000/WeChat/Service%20introduce.html”, 这是我的webview

    webView = (WebView) findViewById(R.id.drive_web);
            webView.setWebViewClient(new WebViewClient());
            webview.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setAppCacheEnabled(true);
            webView.getSettings().setDomStorageEnabled(true);//DOM Storage
        webView.loadUrl("http://dev.51yunche.com:7000/WeChat/Service%20introduce.html");

这个xml:

 <WebView
            android:id="@+id/drive_web"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

控制台没有任何提示或错误消息。我想听听更有经验的WebView用户(和开发人员?)的一些意见。

提前谢谢!

3 个答案:

答案 0 :(得分:1)

这不是webview问题。在网页浏览器中,该网址也显示Nothing.check后端或html文件的设计代码。

答案 1 :(得分:1)

您的网址中有空格编码字符%20 ...

使用有效的网址:

 webView.loadUrl("http://dev.51yunche.com:7000/WeChat/Serviceintroduce.html");

或者,您也可以尝试使用URLEncoder.encode(YOUR_URL);函数对Url进行编码

答案 2 :(得分:0)

您的链接本身不会在网络浏览器中显示任何内容。如果您仍有任何疑问,只需自己创建一个普通的html页面并从本地系统运行并查看它。