O'Reilly logo

50 Android Hacks by Carlos Sessa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. View tips and tricks

In this chapter, you’ll read about different hacks that use views. Most of them show how to customize and/or tweak widgets to perform certain functionalities.

Hack 9 Avoiding date validations with an EditText for dates: Android v1.6+

We all know that validating data in forms is boring as well as error-prone. I worked on an Android application that used a lot of forms and had a couple of date inputs. I didn’t want to validate the date fields, so I found an elegant way to avoid it. The idea is to make users think they have an EditText when it’s in fact a button that will show a DatePicker when clicked.

To make this happen, we’ll change the default background of an Android Button to the EditText’s background. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required