I want to make upper case even if the user write lowercase in edittext
.So I am setting ediText
text to upper case on addTextChangedListener
as per below.
editText.addTextChangedListener(object : TextWatcher{
override fun beforeTextChanged(s : CharSequence?, start : Int, count : Int, after : Int) {
}
override fun onTextChanged(s : CharSequence?, start : Int, before : Int, count : Int) {
editText.setText(s.toString().toUpperCase())
}
override fun afterTextChanged(s : Editable?) {
}
})
But doing this when I type something in editText
, app is hanging and I have to kill the app and restart it again.As I want to use this in binding adapter I can't use AllCaps method of xml