我正在开发一个Android应用程序。它使用WebView加载具有以下组件的表单:
当我填写所有字段然后单击提交按钮,数据将被验证,但是当我从Android键盘单击“开始”按钮时,没有任何反应。我该如何解决?
P / S:我在Android 4.4.4设备上进行调试。答案 0 :(得分:0)
你必须使用html表单和javascript来控制提交。单击Go按钮提交表单;
<form>
<input type='text' id='user_id' />
<input type='password' id='password' />
<input type='button' id='btn_login' />
</form>
<script>
function login()
{
// login code here
}
$('btn_login').click(function() {
login();
});
$('form').submit(function() {
// this event fire on go button click.
login();
return false;
});
</script>
答案 1 :(得分:-1)
For that you need to handle button click event
view.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
Log.i(TAG,"Enter pressed");
//do whatever you were doing in submit button
}
return false;
}
});