How to solve "setOnKeyListener(View.OnKeyListener) in the type View is not applicable for the arguments (new OnKeyListener(){})" error on android?
<p>I'm getting an error with this message "The method setOnKeyListener(View.OnKeyListener) in the type View is not applicable for the arguments (new OnKeyListener(){})"</p>

<p>How can I overcome this problem?</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_first_app);

    ListView myListView =(ListView)findViewById(R.id.myListView);

    final EditText myEditText =(EditText)findViewById(R.id.myEditText);

   final ArrayList&lt;String&gt; toDolist =new ArrayList&lt;String&gt;();

    final ArrayAdapter&lt;String&gt; aa;

    aa=new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,toDolist);

    myListView.setAdapter(aa);

    myEditText.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if(event.getAction()==KeyEvent.ACTION_DOWN)

                if(keyCode==KeyEvent.KEYCODE_DPAD_CENTER){
                    toDolist.add(0,myEditText.getText().toString());

                    aa.notifyDataSetChanged();

                    myEditText.setText("");

                    return true;
                }
            return false;
        }
    });
</code></pre>
