How do I install JqMath on Android? [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-25 04:38:12

问题


I am trying to display some math equations in my Android application, but I am unsure how you use JqMath to display these equations. Could someone tell me step by step what to do to get some simple equations displayed on the Android Application? I have tried the following:

 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", "");

And get the following errors: Unable to open asset URL: file:///android_asset/mathscribe/jqmath-0.4.0.css Unable to open asset URL: file:///android_asset/mathscribe/jqmath-etc-0.4.2.min.js Unable to open asset URL: file:///android_asset/mathscribe/jquery-1.4.3.min.js

I think the problem might be that I need to download some jqMath files to my Android assets folder, but I'm not sure where to find these files.


回答1:


If you don't have the files yet, go to http://mathscribe.com/author/jqmath.html and click the "download jqMath" link in the middle of that page, to download jqMath to your computer. You'll then need to put the correct files in your assets folder.

Also, M.parseMath() should only be applied to a node in the DOM, not a string variable. Your M.parseMath(s); call here is a no-op (does nothing).

You could replace your entire line:

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

with just:

    + "$$x={-b±√{b^2-4ac}}/{2a}$$</body></html>";


来源:https://stackoverflow.com/questions/30263725/how-do-i-install-jqmath-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!