Android Capitalize characters not working in phone

做~自己de王妃 提交于 2019-12-02 08:03:15

Try this:

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

and set EditText xml property to:

android:inputType="text|textCapCharacters"

Hope it helps :)

Try working with this in java class like this :

textView.setText(text.toUpperCase());

you can also use Textwatcher method to apply capitalize on text changed

To make it work from xml you should try this:

android:inputType="textCapCharacters" 
edittext.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {            

}
    @Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {             
}
@Override
public void afterTextChanged(Editable arg0) {
      String s=arg0.toString();
  if(!s.equals(s.toUpperCase()))
  {
     s=s.toUpperCase();
     edittext.setText(s);
  }
}
});     

Try this

<EditText
android:inputType="textCapCharacters" />


<EditText
android:inputType="textCapWords" />

or you can do programmatically in java file

 String str = et.getText.toString().toUpperCase();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!