首页 > 解决方案 > Xamarin - 文件:///android_asset

问题描述

我的应用程序的作用:加载index.html到 WebView

index.html's Code:

<html>
<body>
<a href="Posts10.html"><h2>Interesting Stuff</h2></a>
</body>
</html>

所以每当我点击链接时,它都会给我这个错误:

在此处输入图像描述

index.html并且Posts10.html位于

Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"/CachedPosts"

又名

"/data/user/0/com.companyname.theoctant/files/CachedPosts"

标签: c#androidxamarinwebviewxamarin.forms

解决方案


这可能会有所帮助。来自 Xamarin 文档:

在 Android 上,使用构建操作 AndroidAsset 将 HTML、CSS 和图像放在 Assets 文件夹中,如下所示:

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview?tabs=vswin#android


推荐阅读