I am trying to implement button click handling in my Android app.
In the XML layout file that includes my button, I added the following line to my Button
XML element:
android:onClick="handleClick"
I also defined a method with the following signature in the Activity
that uses this layout:
public void handleClick() { /* ... */ }
However, when I ran my app with this code, it crashed. I was able to fix this crash by updating my method signature to:
public void handleClick(View v) { /* ... */ }
but I don't understand why I am required to include this View
parameter?