Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Turning Edit Fields into Password Fields

In Chapter: Graphical User Interface
Author: Rachee Singh ('racheesingh')
Published? true
FormatLanguage: WikiFormat


You need to designate an EditText as a password field, so that characters the user types will not be visible to "shoulder surfers".


Android provides the password attribute on EditTexts


You might wish to provide a login screen in your application. This would require a username and a password field. While the password field would be an EditText, it should be modified a little bit. It should hide the characters after they are typed. This can be done by adding a property to the EditText in XML:


With this new property, this is how the EditText in which password is being entered, looks:


If you found this recipe useful, why not buy the book and have the whole collection always at hand?"