Implicit “Submit” after hitting Done on the keyboard at the last EditText Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Implicit “Submit” after hitting Done on the keyboard at the last EditText without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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?

Answer

Try this:

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" />

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;
     }
 });

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

We are here to answer your question about Implicit “Submit” after hitting Done on the keyboard at the last EditText - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji