How to Apply the Textchange event on EditText

前端 未结 7 1356
感动是毒
感动是毒 2020-12-13 13:38

I developed one simple app, like subtraction, addition. In this app I use three EditTexts, one for answer and other two for question. I want to calculate the answer of quest

7条回答
  •  误落风尘
    2020-12-13 14:19

    For Kotlin use this below code

    edit1.addTextChangedListener(object : TextWatcher {
       override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
           if (edit1.text.toString().length == 1) {
                 edit2.requestFocus()
           }
       }
    
       override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int
       ) {// TODO Auto-generated method stub
       }
    
       override fun afterTextChanged(s: Editable) {}
    })
    

提交回复
热议问题