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

95. Increment and Decrement the Date Picker

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 shows how to increment and decrement values inside our custom date picker widget after detecting the compound drawable clicks. Use the getCompoundDrawables method of the TextView to get a list of attached compound drawables and check if we have a valid top and bottom drawable. We get the coordinates of the MotionEvent using getX and getY and check the conditions needed to classify a click as a top drawable click or bottom drawable click. In the last step, get a Calendar object and call add method to increment or decrement the desired quantity by 1 and use the SimpleDateFormat class to display months appropriately.

Course Cirriculum