【发布时间】:2017-04-10 13:23:32
【问题描述】:
我创建了一个 HTML 文件并将其添加到 assets 文件夹中。我像这样在 axml 文件中添加了一个 webview
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/LocalWebView">
</WebView>
并尝试使用以下代码加载它
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Teams);
WebView localWebView = FindViewById<WebView>(Resource.Id.LocalWebView);
localWebView.LoadUrl("file:///android_asset/Content/Teams.html");
}
它告诉我找不到文件。除了资产文件夹之外,还有其他地方我必须添加 html 页面或我必须做的其他事情吗?
【问题讨论】:
-
您确定您的文件在您的项目
assets/内您认为的位置吗? -
是的,其中唯一的其他文件是“aboutassets”。应该是这样吗?
-
Is there somewhere other than the assets folder I have to add the html page。您应该将其添加到资产中的“内容”文件夹中。 -
我也有内容文件夹
-
我在 axml 上的“WebView”元素上有一个警告,它没有声明,但在活动页面上它仍然找到它的 ID。和这个有关系吗?