setOnClickListener(new OnClickListener(){})
<pre><code>package android.example;

import android.app.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class Android_eg1 extends Activity {
    Button bt; 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        bt=(Button)findViewById(R.id.click);
        bt.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
            // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show();
            }

        });
      } //onCreate()

}//class
</code></pre>

<p>I am new to java and I know basics of core java. 
This is the sample program i tried to know about the event handling through a button class.
I could not understand this part :</p>

<pre><code>"bt.setOnClickListener(new OnClickListener(){
        public void onClick(View v) {
        // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show();
        }

    });"
</code></pre>

<p>Inside the setOnClickListener(parameter) why are they giving a function definition?(public void onClick(View v) })</p>

<p>Is this acceptable?</p>
