Reputation: 6197
In my programme, there are textview button scrollview and webview. All of them write by java except webview(write by html js/jquery). Is that availabe to trigger some javascript when I click button(clicklistener write by java android google api)? Basically, my programme receives some data from tcp response (json type data) and save in a json file. jquery library plot retrieve that file and draw graph. There are two buttons. One is for retrieving data and another one is drawing graph. Because they and java and javascript. Is there any way when I click the retrieving button, the graph will auto drawing? How to interact java and javascript? Thanks!!!
Upvotes: 0
Views: 791
Reputation: 1459
You can run JavaScript from java in your webview this way:
onCreate I do this:
webView = (WebView)findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.de/");
On click on a button this happens:
public void onClick(View v) {
webView.loadUrl("javascript:document.bgColor = '#a00';");
}
Should change the bg-color of your document to red which works perfectly fine for me with google.de
Upvotes: 1