Keep a local variable and set it to the appropriate button’s id whenever a button is pressed.
int lastPressedButton;
...
@Override
public void onClick(View v) {
lastPressedButton = v.getId();
switch(v.getId()) {
// normal button handling code
}
}
0
solved How to know which Button was pressed recently among all the Buttons in an activity?