One OnClickHandler for multiple Buttons

You can also set it in your layout xml using the android:onclick attribute.

android:onClick="onClick"

Then in your activity class add the onClick method.

public void onClick(View v) {
...

Here’s the documentation.

Leave a Comment