我使用过一些应用程序,当我填写用户名,然后转到密码时,如果我在键盘上点击“完成”,则会自动提交登录表单,而无需单击提交按钮。这是怎么做到的?
尝试这个:
在您的布局中放置/编辑以下内容:
<EditText
android:id="@+id/search_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:singleLine="true"
android:imeOptions="actionDone" />
在您的活动中放入以下内容(例如在 onCreate 中):
// your text box
EditText edit_txt = (EditText) findViewById(R.id.search_edit);
edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
submit_btn.performClick();
return true;
}
return false;
}
});
Where submit_btn
是您的提交按钮,附加了您的 onclick 处理程序。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)