Android - WebView = 网页不可用 [英] Android - WebView = Web page not available
本文介绍了Android - WebView = 网页不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用中使用 WebView
视图时,无论我强制它访问哪个页面,它都会显示未找到网页.这是我的代码:
When using a WebView
view in my app, no matter what page I force it to visit, it says Web page not found. Here is my code:
MainActivity.java
package com.testing.webview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class MainActivity extends Activity
{
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = webView.getSettings();
webSettings.setBuiltInZoomControls(true);
webView.loadUrl("http://www.google.com");
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
如您所见,这是非常基本的代码.确实有互联网连接,因为我可以打开普通的浏览器应用程序并像平常一样访问任何网页.
It's very basic code as you can see. There is indeed an internet connection as I can open the normal Browser app and visit any webpage like normal.
推荐答案
您是否使用了正确的 Internet 权限?
Are you using the correct Internet permission?
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
这篇关于Android - WebView = 网页不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文