简体   繁体   中英

How do I prevent user from typing specific characters from the keyboard in android studio?

for example, when user touches the characters on the keyboard (a to z) nothing is typed in the Edit Text (Even though it's focused), but when he touches any of the numbers it IS typed in the Edit text. I don't want to change the keyboard itself(or create a custom keyboard) I just want to filter some of the characters. How do I do it? Thank you in advance :)

in EditText xml:

android:digits="1234567890"

this will allow only numbers

它将允许用户仅键入小写字母,也可以添加数字和特殊字符。

<Edittext android:digits="abcdefghijklmnopqrstuvwxyz"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM