问题
I recently came across the JSObject and JSFuntion, and it seemed really confusing. Can it be used to call custom JavaScript functions and return values back to my CN1 app? Or is it for some other function?. Thanks all
回答1:
Check out the javadoc package overview for that: https://www.codenameone.com/javadoc/com/codename1/javascript/package-summary.html
E.g. from that page:
The following example shows an object with a simple add() method that just adds two numbers together:
JSObject obj = (JSObject)ctx.get("{ add : function(a,b){ return a+b;}}");
Double result = (Double)obj.call("add",
new Object[]{new Integer(1), new Integer(3)}
);
// Result should be 4.0
来源:https://stackoverflow.com/questions/39417360/calling-custom-javascript-function-from-codename-one