I want to set text in textview in my android class using JavaScript which contains a same named variable as in the class for textview to which I want to assign some text. Something like this:
In js:
function validClick() {
fromJS.append("vikrant");
valid.performClick();
document.getElementById("ok").value = "Accepte";
}
fromJS is my textview in android class.
and the code in the class looks like:
valid.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Context context = getApplicationContext();
CharSequence text = fromJS.getText();
CharSequence text = clsVariable;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
});
Also, I'm writing
wbvw.addJavascriptInterface(valid, "valid");
wbvw.addJavascriptInterface(fromJS, "fromJS");
in my onCreate method.
Check out this link. I think it uses TextView and javascript to lad data to it.
http://divineprogrammer.blogspot.in/2009/11/javascript-rhino-on-android.html
doit(
"var widgets = Packages.android.widget;\n" +
"var view = new widgets.TextView(TheActivity);\n" +
"TheActivity.setContentView(view);\n" +
"var text = 'Hello Android!\\nThis is JavaScript in action!';\n" +
"view.append(text);"
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.