隐[提交"击球完成在键盘上在最后的EditText后 [英] Implicit "Submit" after hitting Done on the keyboard at the last EditText

查看:134
本文介绍了隐[提交"击球完成在键盘上在最后的EditText后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的一些应用程序在那里,当我填写了用户名,然后进入我的密码,如果我打完成,登录表单自动提交,在键盘上没有我不得不点击提交按钮。这是怎么做的?

I've used some apps where when I fill my username, then go to my password, if I hit "Done" on the keyboard, the login form is automatically submitted, without me having to click the submit button. How is this done?

推荐答案

试试这个:

在你的布局认沽/编辑这样的:

In your layout put/edit this:

<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):

In your activity put this (e. g. in 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;
     }
 });

其中,的submit_btn 与您的onclick处理程序连接您的提交按钮。

Where submit_btn is your submit button with your onclick handler attached.

这篇关于隐[提交&QUOT;击球完成在键盘上在最后的EditText后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆