Android EditText Password box By default is small dot how to change to other (*)?

Source: Internet
Author: User

Text.settransformationmethod (NewAsteriskpasswordtransformationmethod ());  Public classAsteriskpasswordtransformationmethodextendsPasswordtransformationmethod {@Override Publiccharsequence gettransformation (charsequence source, view view) {return Newpasswordcharsequence (source); }             Private classPasswordcharsequenceImplementsCharsequence {Privatecharsequence Msource;  Publicpasswordcharsequence (charsequence source) {Msource= Source;//Store Char sequence        }           Public CharCharAt (intindex) {              return‘*‘;//The important part        }           Public intLength () {returnMsource.length ();//Return Default        }           PublicCharsequence subsequence (intStartintend) {              returnMsource.subsequence (start, end);//Return Default        }      }  

Textview:setinputtype (). Settransformationmethod ()

In some cases, it may be necessary to run a TextView (perhaps created at runtime or written in an XML file) in a seasonal operation. Since it is not possible to specify it as a password input property through an XML file, how does this work?

There are two methods of TextView:

Setinputtype (int) settransformationmethod (Transformationmethod)

Setinputtype can change the way TextView is entered: contact, Email, Date, time, short Message, Normal Text, Password, and so on. You can also specify a variety of correction options, such as capitalize the first letter of the word, capitalize the sentence, AutoCorrect, and so on.

How to use:

  int InputType = Inputtype.type_class_text | Inputtype.type_text_flag_auto_correct                      | Inputtype.type_text_flag_multi_line | Inputtype.type_text_flag_auto_correct                      | Inputtype.type_text_variation_short_message;       Textview.setinputtype (inputtype);

Settransformationmethod, in turn, can support the conversion of input characters, including the elimination of line breaks, and conversion to masks. How to use:

Textview.settransformationmethod (Passwordtransformationmethod.getinstance ());

In general, if you need to implement your own conversion, you can achieve your goal by implementing the Transformationmethod interface (such as making all the characters you enter a, or entering a display z, input z display a, and so on).

Android EditText Password box By default is small dot how to change to other (*)?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.