Design + Code an Android App from Scratch
This video demonstrates the different ways to handle clicks on a button using a simple login form. The first method uses an onClick attribute in XML where you specify the name of a method from java code that should be called when the Button is Clicked. Ensure that the method exists and takes a View argument as input parameter. The second way is to have your Activity implement the OnClickListener which has a single method called onClick that tells you which View was clicked in the form of its parameter. Initialise the Button in code and don’t forget to set the OnClickListener for it.