WebView webView = (WebView)findViewById(R.id.display);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
String path="file:///android_asset/";
String js = "<html><head>"
+ "<link rel='stylesheet' href='"+path+"jqmath-0.4.3.css'>"
+ "<script src='"+path+"jquery-1.4.3.min.js'></script>"
+ "<script src='"+path+"jqmath-etc-0.4.5.min.js'></script>"
+ "</head><body>"
+ "$$x={-b±√{b^2-4ac}}/{2a}$$</body></html>";
webView.loadDataWithBaseURL( "file:///android_asset/" ,js, "text/html", "UTF-8", null);我将我从here下载的所有文件都添加到assets文件夹中,但当我运行应用程序时得到的都是$$x={-b±√{b^2-4ac}}/{2a}$$,而不是预期的等式。我是不是遗漏了什么。
发布于 2017-07-13 03:18:30
检查你的路径,这是由于你的文件的路径错误,我猜你已经在assets中存储了mathscribe文件夹,然后你正在使用这段代码,如果你已经在asset中保存了完整的文件夹mathscribe,你必须修改路径。新路径
String path = "file:///android_asset/mathscribe/"希望这将是有帮助的.
发布于 2018-01-07 21:20:27
js变量中的文件名必须与assets文件夹中的文件名相同。我认为您已经下载了最新版本的文件,但复制粘贴了某个较旧线程中的代码。
https://stackoverflow.com/questions/44671295
复制相似问题