How to transform text introduced in a edittext into password style (*****)?
I need to do that, like when you put the PIN code in your phone, the numb开发者_运维知识库ers transforms into stars (**).
Is there a way to do that in the layout xml file? If not, is there a way to do it with java?
http://developer.android.com/reference/android/widget/TextView.html#attr_android:password
<EditText
android:id="@+id/Text_password"
android:password="true"
android:layout_width="80dip"
android:singleLine="true"
android:inputType="text"
android:hint="Password"
android:layout_height="wrap_content">
To do it using code:
fieldname.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance());
I solved it. You have to put android:password="true"
on the xml.
精彩评论