I was tryin to find any class to define a password field? How can we do that? Do we have a class for that or some method to edittext?
+2
A:
In the xml layout file try assigning this property to your edittext...
android:password="true"
Ryan
2009-12-24 12:12:30
+5
A:
There are a couple of ways of doing this.
The first (apparently) deprecated, is to set this property on the widget in your layout resource file
android:password="true"
From code this is equivalent to calling:
myEditTextWidget.setTransformationMethod(new PasswordTransformationMethod());
(note that this also gives you the flexibility to supply your own implementation of the TransformationMethod
interface).
The second mechanism is to set this property:
android:inputType="textPassword"
again, equivalent to calling:
myEditTextWidget.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD);
Alnitak
2009-12-24 12:12:38
+2
A:
Better to use the inputType property, the password one is now deprecated.
<EditText android:id="@+id/password" android:inputType="textPassword"/>
Mirko Nasato
2009-12-24 12:18:36
Which SDK release deprecated it? 70% of Android devices are still running Android 1.6 or earlier.
Alnitak
2009-12-24 12:21:48
And from code, that's setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD).
Mirko Nasato
2009-12-24 12:22:10
Don't know when 'password' was deprecated, but inputType works at least since Android 1.5.
Mirko Nasato
2009-12-24 12:33:35
thanks for the extra info - I've collated in my answer so it's all in one place.
Alnitak
2009-12-24 12:42:02