【发布时间】:2013-08-31 03:37:32
【问题描述】:
我正在尝试使用DOT42 在 C# 中编写代码。如何导航到我的资产文件夹中的 html。我使用以下代码在 java 中实现了与 Eclipse 相同的功能:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://www.google.com";
url="file:///android_asset/out/in/active_deals.html";
WebView webv = (WebView) findViewById(R.id.webview1);
WebSettings settings = webv.getSettings();
settings.setJavaScriptEnabled(true);
webv.setWebViewClient(new WebViewClient());
webv.loadUrl(url);
}
当我尝试在 C# 中使用 DOT42 执行相同操作时,它显示页面未找到:
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
string url = "";
//url = "http://www.google.com";
url = "file:///Android_Asset/out/in/active_deals.html";
WebView myWebView = (WebView)FindViewById(R.Ids.webview1);
myWebView.SetWebViewClient(new WebViewClient());
myWebView.LoadUrl(url);
WebSettings webSettings = myWebView.GetSettings();
webSettings.SetJavaScriptEnabled(true);
}
我试过用小写和大写命名资产文件夹,似乎都不起作用。 我试过'Android_Asset'、'android_asset'、'Asset',但都没有奏效。不过它适用于 Eclipse。
【问题讨论】: