无法在mono android中加载html资源
当我在VisualStudio2010(mono android)中访问Assets文件夹中的html文件时,我得到一个错误无法在mono android中加载html资源,android,visual-studio-2010,xamarin.android,Android,Visual Studio 2010,Xamarin.android,当我在VisualStudio2010(mono android)中访问Assets文件夹中的html文件时,我得到一个错误 invalid resource directory name : assets 在单安卓中 我尝试过这些代码组合,但没有用 //webView.LoadUrl("file:///android_asset/mapapp/index.html"); //webView.LoadUrl("file:///AndroidAsset/mapa
invalid resource directory name : assets
在单安卓中
我尝试过这些代码组合,但没有用
//webView.LoadUrl("file:///android_asset/mapapp/index.html");
//webView.LoadUrl("file:///AndroidAsset/mapapp/index.html");
//webView.LoadUrl("file:///android_asset/mapapp/index.html");
//webView.LoadDataWithBaseURL("file:///android_asset/mapapp", "index.html", "text/html", "UTF-8", null);
webView.LoadUrl("file:///AndroidAsset/TextFile1.html");
看看这个,
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.WebView;
public class StackOverFlowActivity extends Activity {
private Handler mHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView view=(WebView)findViewById(R.id.webView1);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl("file:///android_asset/index.html");
view.addJavascriptInterface(new MyJavaScriptInterface(), "Android");
}
final class MyJavaScriptInterface
{
public void ProcessJavaScript(final String scriptname, final String args)
{
mHandler.post(new Runnable()
{
public void run()
{
//do anything here...
}
});
}
}
}
如果您的html文件位于assets文件夹内,请尝试上述操作
如果它放在任何文件夹中,请给出类似的
view.loadUrl("file:///android_asset/image/index.html");
我有几个图标和图像被mono android视为AndroidResource,将它们更改为AndroidAsset删除了错误。应该完全相同。尝试创建一个新的测试项目,其中只有一个webview和一个资产。不过,不需要javascript接口。