我的应用程序中的 webview 没有显示。我去互联网寻找答案,但我什么也没找到,只是有关如何使用控件的教程。我正在尝试加载一个 html 文件,但它没有显示。
我在清单中添加了用户权限“Internet”。
这是我的布局:
<TableLayout 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" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:visibility="visible" >
<WebView
android:id="@+id/wvInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</TableRow>
</TableLayout>
我的资产文件夹中有一个文件“filename.html”。
以下代码在 onCreate 中:
WebView wvinfo = (WebView) findViewById(R.id.wvInfo);
wvinfo.loadUrl("file:///android_asset/filename.html");
当我在手机上加载程序时,什么也没有出现。我还尝试加载一个网址“ http://www.google.com ”,但仍然没有显示。我难住了。有任何想法吗?