0

我正在尝试在我的 Android 应用程序中显示一些数学方程式,但我不确定您如何使用 JqMath 来显示这些方程式。有人可以逐步告诉我如何在 Android 应用程序上显示一些简单的方程式吗?我尝试了以下方法:

 mEquationWebView = (WebView)v.findViewById(R.id.equation_webView);
    WebSettings mWebSettings = mEquationWebView.getSettings();
    mWebSettings.setJavaScriptEnabled(true);
    String path="file:///android_asset/";
    String js = "<html><head>"
            + "<link rel='stylesheet' href='file:///android_asset/mathscribe/jqmath-0.4.0.css'>"
            + "<script src = 'file:///android_asset/mathscribe/jquery-1.4.3.min.js'></script>"
            + "<script src = 'file:///android_asset/mathscribe/jqmath-etc-0.4.2.min.js'></script>"
            + "</head><body>"
            + "<script>var s =   '$$x={-b±√{b^2-4ac}}/{2a}$$';M.parseMath(s);document.write(s);</script> </body>";
    mEquationWebView.loadDataWithBaseURL("",js,"text/html", "UTF-8", "");

并得到以下错误: 无法打开资产 URL:file:///android_asset/mathscribe/jqmath-0.4.0.css 无法打开资产 URL:file:///android_asset/mathscribe/jqmath-etc-0.4.2 .min.js 无法打开资产 URL:file:///android_asset/mathscribe/jquery-1.4.3.min.js

我认为问题可能是我需要将一些 jqMath 文件下载到我的 Android 资产文件夹中,但我不确定在哪里可以找到这些文件。

4

1 回答 1

1

如果您还没有这些文件,请访问http://mathscribe.com/author/jqmath.html并单击该页面中间的“下载 jqMath”链接,将 jqMath 下载到您的计算机。然后,您需要将正确的文件放入您的资产文件夹中。

此外, M.parseMath() 应该只应用于 DOM 中的节点,而不是字符串变量。您M.parseMath(s);在这里的电话是无操作的(什么都不做)。

您可以替换整行:

    + "<script>var s =   '$$x={-b±√{b^2-4ac}}/{2a}$$';M.parseMath(s);document.write(s);</script> </body>";

只需:

    + "$$x={-b±√{b^2-4ac}}/{2a}$$</body></html>";
于 2015-05-16T18:16:29.353 回答