Catch "DONE" key press from soft keyboard
<p>I'm looking for code that can catch key press of "DONE" button from soft keyboard. When done button is pressed, I need to change button state to enabled and user then can move on to the next activity.</p>

<p>I found this piece of code, here on stackoverflow, but I can't implement it without errors. Can you help me please?</p>

<pre><code>editText = (EditText) findViewById(R.id.edit_text);

editText.setOnEditorActionListener(new OnEditorActionListener() {
   @Override
   public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
       if (actionId == EditorInfo.IME_ACTION_DONE) {
           // do your stuff here
       }
       return false;
}
});
</code></pre>

<p>Here is entire .java file</p>

<pre><code>package com.example.start201;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class FirstActivity extends Activity {

   private EditText editText;

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.layout_firstactivity);

       editText = (EditText) findViewById(R.id.editText2);

       editText.setOnEditorActionListener(new OnEditorActionListener() {
           @Override
           public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
               if (actionId == EditorInfo.IME_ACTION_DONE) {
                   // do your stuff here
               }
               return false;
           }
       });

}


}
</code></pre>
