It's what you say. When you create the button, you do it through an ID, when you send it to the -one function- you recover it using the same ID, in this case through the getId () function of each View.
We create the listener:
View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
pressed(view);
}
};
We add it to the buttons:
v.findViewById(R.id.boton_sumar).setOnClickListener(onClickListener);
v.findViewById(R.id.boton_restar).setOnClickListener(onClickListener);
//...y el resto de botones.
And in the function:
private void pressed(View view){
switch(view.getId()){
case R.id.boton_sumar:
//Lo que sea para sumar...
break;
case R.id.boton_restar:
//Lo que sea para restar...
break;
case R.id.etc:
break;
}
}