开发者

How to transform text introduced in a edittext into password style (*****)?

开发者 https://www.devze.com 2023-01-24 07:22 出处:网络
I need to do that, like when you put the PIN code in your phone, the numb开发者_运维知识库ers transforms into stars (**).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消