【问题标题】:Dot 42 - Navigate to HTML in Asset Folder点 42 - 导航到资产文件夹中的 HTML
【发布时间】: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。

【问题讨论】:

    标签: android dot42


    【解决方案1】:

    当您将嵌入式资源添加到您的 Visual Studio 项目时,它将被转换为您的 APK 中具有完整命名空间名称的资产。

    以这个网址为例:

    var url = "file:///android_asset/dot42AssetWebView.Resources.Index.htm";

    它适用于命名空间 "dot42AssertWebView.Resources" 中名为 Index.htm 的嵌入式资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 2012-09-05
      • 2013-10-29
      相关资源
      最近更新 更多