EditText properties have been encapsulated in the relevant settings, the previous article also mentioned, unfamiliar can go to see the previous EditText attribute Daquan, here focus on the input restriction properties: android:digits= "1234567890.+-*/%\n ( "Limit input boxes can only enter their own definition of these strings if the input other will not be displayed android:phonenumber=" true "limit input box can only enter mobile phone number android:password=" true " Any content entered in the Restrict input box will display the text in the input box by default in the "*" sign android:hint= the "default text" entry android:textcolorhint= "#FF0000" to set the text content color Android: Enabled= "false" setting input box cannot be edited if there are some special restrictions, such as I do a project can only enter a number, and enter 0 and then enter 1, then only show 1, which needs to be set up separately, and very simple. Add a listening event to EditText, when the content changes inside the detection, according to the needs, modify the relevant content can be. EditText is monitored using EditText's addtextchangedlistener (Textwatcher Watcher) method, Textwatcher is an interface class, So the abstract method in Textwatcher must be implemented:
The above is the online copy, if the code to control the input restrictions
Edittext.setinputtype (Editorinfo.type_class_phone);
Android EditText set input limit, can only enter a number