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

Published? true
FormatLanguage: WikiFormat

Problem:

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

Solution:

Android provides the password attribute on EditTexts

Discussion:

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:

android:password="True"        

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