我的应用程序中的webview没有显示出来。我去互联网找到答案,但我什么都没找到,只是教程如何使用控制。我正在尝试加载一个html文件,但没有显示。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");
当我打开我的手机上的程序,什么也不显示。我也尝试加载一个url,“http://www.google.com”,但仍然没有显示。我很难过。有任何想法吗?
的本地文件,我会用'loadData(HTML, “text/html的”,NULL);'。您还可以向我们展示清单或您编辑的部分。 – Gjordis