Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

33. Event Handling in Layouts

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

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