Multiple editText implementation monitoring

 Add the addTextChangedListener method to each editText

        binding.desEdit.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) {
            }

            override fun afterTextChanged(s: Editable?) {
                val num = 50 - s.toString().length
                binding.desMaxNumber.text = "$num"

            }

        })

Guess you like

Origin blog.csdn.net/qq_41264674/article/details/131789204