Android EditText set input limit, can only enter a number

Source: Internet
Author: User
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

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.