How do I install JqMath on Android? [duplicate]
Asked Answered
H

1

0

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.

Hamo answered 15/5, 2015 at 15:49 Comment(0)
U
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>";
Undistinguished answered 16/5, 2015 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.