0

What is the purpose for the the empty parentheses following onClickListener in this snippet of Android code? (I'm wondering, since onClickListener is an interface.)

Button btn = (Button) findViewById(R.id.mybutton);

btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    myFancyMethod(v);
    }
});
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
sibi
  • 59
  • 3
  • Welcome to StackOverflow. It may be possible that the answer is related to the contents in [this question](http://stackoverflow.com/questions/21918423/explicit-casting-on-objects-with-interface-whats-the-use-of-parentheses). You can find useful tips to improve your questions and answers in the [Help Center](http://stackoverflow.com/help) – SebasSBM Feb 03 '16 at 17:56
  • Possible duplicate: http://stackoverflow.com/questions/4000062/can-we-create-an-object-of-an-interface – Eric Brandwein Feb 03 '16 at 18:11

0 Answers0