title: OnClickListener interface in Android
body: <p>I am new to programming, I have very basic knowledge in android. As I learned in java that an Interface cannot be instantiated And that <code>new</code> is a keyword in Java that indicates creating an instance. I came across following code in Android:</p>
  
  <pre><code>public class MyActivity extends Activity {
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
  
      setContentView(R.layout.mylayout);
      findViewById(R.id.button1).setOnClickListener(mButton1_OnClickListener);
    }  
  
    //On click listener for button1
    final OnClickListener mButton1_OnClickListener = new OnClickListener() {
      public void onClick(final View v) {
          //Inform the user the button has been clicked
          Toast.makeText(this, "Button1 clicked.", Toast.LENGTH_SHORT).show();               
      }
    };
  }
  </code></pre>
  
  <p>Above code <code>OnClickListener</code> is a public interface and <code>onClick(final View v)</code> is an abstract method, Here goes my question: <code>OnClickListener</code> being an interface, how is possible to create an instance of it by using the <code>new</code> keyword in the example above?</p>