Handling Button click by using OnClickListener:
In this way, we identify the button. After that, a listener is set to listen to the click of Button. The listener is OnClickListener.
Ex: In Activity, declare button and initialize in onCreate
Button b;
b = (Button)findViewById(R.id.button);
//Set OnClickListener
b.setOnClickListener(new OnClickListener(){
public void onClick(View v){
// Write the logic on button click
}
}