inside OnCreate method :-
{
Button b = (Button)findViewById(R.id.button1);
b.setOnClickListener((View.OnClickListener)this);
b = (Button)findViewById(R.id.button2);
b.setOnClickListener((View.OnClickListener)this);
}
@Override
public void OnClick(View v){
switch(v.getId()){
case R.id.button1:
//whatever
break;
case R.id.button2:
//whatever
break;
}