If someone wants to do this in kotlin and with data binding, please refer below code
//first get reference to your edit text var editText:EditText = viewDataBinding.editText // add listner on edit text editText.setOnFocusChangeListener { v, hasFocus -> if(!hasFocus) { if((editText.text.toString().toIntOrNull()>10) {// add any thing in this block editText.text = "10" } } }
source share