I'm beginning android development and was going through some guides in which I tumbled across this piece of code :

 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)
        {
          todoItems.add(0, myEditText.getText().toString());
          aa.notifyDataSetChanged();
          myEditText.setText(“”);
          return true;
        }
      return false;
    }
  });

I would like to ask, what kind of parameter is the method "myEditText.setOnKeyListener" taking? It looks confusing to me because it contains new keyword, bunch of codes in curly braces, return...etc etc.... Anyone please explain.....

regards,

Recommended Answers

All 2 Replies

Google: anonymous inner class java

Ok, Got it! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.