在Android中的EditText,如何强制写大写Android、EditText

2023-09-14 23:01:57 作者:哼唱

在我的Andr​​oid应用我有不同的EditText用户可以在其中输入信息。但是我需要强制用户在大写字母写... 你知道一个函数来做到这一点?

in my Android application I have different EditText where the user can enter information. But I need to force user to write in uppercase letters... Do you know a function to do that ?

谢谢!

推荐答案

安卓实际上已经建立了一个 -IN输入过滤器只为这!

Android actually has a built-in InputFilter just for this!

edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});