Create your account

Already have an account? Login here

Create account

33. Event Handling in Layouts

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to buy this course, or login to your account to view this lesson.

Alright, buy it for $25 Or login to your account if you purchased already.

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.

Course Cirriculum