使用TextWatcher时如何修复EditText滞后

时间:2019-11-13 13:42:23

标签: android android-textwatcher

下面,我添加了我的代码,当我尝试编辑我的电话号码文本且没有任何显示时,键盘滞后了

phoneNumberText.addTextChangedListener(object: TextWatcher {
            override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {

            }

            @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
            override fun afterTextChanged(s: Editable?) {

              val string =   PhoneNumberUtils.formatNumber("+961 11234567","Lebanon")
                val stringToAppend = string.drop(5)
                s!!.replace(0,s.length,stringToAppend)
                Log.d(TAG,stringToAppend)


            }

            override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {

            }
        })

Log.d输出正常,正在格式化 预先感谢

0 个答案:

没有答案