While learning about Event Handling in android I came across the below code
Here are few questions that I have
1) Why an instance of an anonymous class that is implementing the View.OnClickListener() interface is passed as an argument to setOnClickListener()?
2) What is the benefit of passing this instance as an argument?
Button button = (Button) findViewById(R.id.button_send);
button.setOnClickListener(new View.OnClickListener() // explain this {
public void onClick(View v) {
// Do something in response to button click
}});