Issues overriding onKey in View.OnKeyListener
<p>I am new to Android programming and relatively new to programming in general so please bear with me here...</p>

<p>I am trying to implement an EditText field and I am having problems with overriding onKey. </p>

<p>I found a couple of errors and fixed them but when I compile I get the following error:</p>

<pre><code>cs211d.hw03.HW03 is not abstract and does not override abstract method       onKey(android.view.View,int,android.view.KeyEvent) in android.view.View.OnKeyListener
[javac] public class HW03 extends Activity implements View.OnKeyListener
</code></pre>

<p>I tried moving the <code>onKey</code> method outside of the inner class and it worked but only if I commented out <code>et.setOnKeyListener(...);</code></p>

<p>Somebody suggested in another forum that I remove the <code>OnKeyListener</code> and/or <code>implements View.OnKeyListener</code> but it seems like it should be possible to implement the interface and use the <code>OnKeyListener</code>....otherwise what is the point of it's existence?</p>

<p>Here is my code:</p>

<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.EditText;

public class HW03 extends Activity implements View.OnKeyListener
{
    final EditText et = (EditText) findViewById(R.id.penniesField);

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

        et.setOnKeyListener(
            new View.OnKeyListener()
            {
                public boolean onKey(View v, int keyCode, KeyEvent ke)
                {
                    if( (ke.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp;
                        (keyCode == KeyEvent.KEYCODE_ENTER) )
                    {
                        String pennies = et.getText().toString();
                        return true;
                    }
                    return true;
                }
            });
    }
}
</code></pre>
