Create your account

Already have an account? Login here

Create account

47. Event Handling For Button

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 shows how to handle Button clicks in Android. There are 5 different ways for doing this. Use the android:onClick attribute in XML and give some method name as the value of this attribute. Define this method inside the Activity and ensure it takes a View argument. As an alternative you can let your Activity or Fragment implement the View.OnClickListener which is an interface with a single method called onClick. Set this listener on the Button by saying setOnClickListener. The other methods revolve around the different ways of doing this which would involve either implementing the Listener directly in the Activity or Fragment or using anonymous inner classes.

Course Cirriculum