How to listen to software keyboard done button in android?

By | November 11, 2011

Here is a simple method to listen to software keyboard done button in android while editing in an EditText.

package pack.coderzheaven;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;

public class KeyBoardTest extends Activity {

    public void onCreate(Bundle savedInstanceState) {

                new EditText.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH ||
                    actionId == EditorInfo.IME_ACTION_DONE ||
                    event.getAction() == KeyEvent.ACTION_DOWN &&
                    event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {

                		System.out.println("DONE BUTTON PRESSED............");

                    return true;
                return false;


Leave a Reply

Your email address will not be published. Required fields are marked *