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 FieldsBack to Android Cookbook Home | Up to Chapter: Graphical User Interface

Author: Rachee Singh ('racheesingh')
In Published Edition? Yes
FormatLanguage: WikiFormat

Turning Edit Fields into Password Fields


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:

See Also