Chi*_*tan 5 html javascript java jquery android
我加载了一个Html页面WebView.在我加载页面后填写的Html页面中有四个TextAreas存在,当我填充它们时,我想获得点击我的Android中的Next的值(下一个按钮在Android中不在Html页面中)但是,我不能获取Android中的值.所以请帮助我.提前致谢.WebViewTextAreas ButtonTextAreas
这是我加载的Html页面WebView.

在 HTML 页面中,链接到“确定”按钮:
function ok() {
var t1 = document.getElementById("textarea1").value;
var t2 = document.getElementById("textarea2").value;
var t3 = document.getElementById("textarea3").value;
var t4 = document.getElementById("textarea4").value;
var result = JSON.parse(bridge.doIt(t1,t2,t3,t4));
}
}
Run Code Online (Sandbox Code Playgroud)
在应用程序的网络视图中:
class MyBridge {
public MyBridge(Context context) {
// ...
}
@JavascriptInterface
public String doIt(String t1,
String t2,
String t3,
String t4) {
// do whatever you want here with the values
}
}
Run Code Online (Sandbox Code Playgroud)
并在 webview 的构造函数中:
this.addJavascriptInterface(new MyBridge(pContext), "bridge");
Run Code Online (Sandbox Code Playgroud)
这应该可行(我自己使用它)。如果您不想使用“确定”按钮,则必须稍微更改代码以满足您的需求,也许在文本字段的“onKeyPress”上调用一个函数。
| 归档时间: |
|
| 查看次数: |
759 次 |
| 最近记录: |