我試過了這段代碼,並停留了很多天。
其實我想要的是整合mathjax庫爲mathametics公式,並獲得輸出形式。得到值的形式Android調用JavaScript函數,並將其返回給js
<html>
<head>
<style>
body{
background-color: #FA5858;
color:#fff;
}
input{
background-color: #F7D358;
width: 300px;
padding:10px;
color: #000;
}
div#content{
padding:20px;
background-color: #F7D358;
color: #000;
}
</style>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
function showAndroidToast(toastmsg) {
var x= Android.showToast(toastmsg);
return x;
}
function testcall(toastmsg){
alert(showAndroidToast(toastmsg));
}
</script>
</head>
<body>
<center>
<h3>Binding JavaScript code to Android code</h3>
<div id="content">
</div>
<div>
Here are few examples:
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</div>
<div>
<input type="button" value="Make Toast" onClick="testcall('Toast made by Javascript New:)')" /><br/>
</div>
</center>
</body>
</html>
這在我的Android代碼
public class WebAppInterface {
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
/**
* Show Toast Message
* @param toast
*/
public String showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
String test="\\hspace1ex \\color{blue} {Simplify:} \\hspace1ex 2x(3x+2xy)";
return test;
}
}
但我的Android代碼沒有任何vaule返回javascript函數。
任何幫助表示讚賞。
一樣,
這是我的Android功能
public String showToast() {
String test="\\hspace1ex \\color{blue} {Simplify:} \\hspace1ex 2x(3x+2xy)";
return test;
}
and in javascript i want the value that is return by this showToast() function
感謝
你如何初始化的網頁視圖?請張貼更多一點的代碼:) – PaMaDo 2015-04-02 10:06:42