如何在editText之前添加一个字符?

How to add a character before editText?

我需要用户键入 11 位数字,但如果他键入的数字较少,则在键入的文本之前会出现零。 示例:

11位文字: 52396514262

如果用户只输入523: 我希望编辑文本出现 00000000523

cpf_formulario_abastecimento.addTextChangedListener(object  : TextWatcher{
        override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

        }

        override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

        }

        override fun afterTextChanged(p0: Editable?) {
            for (i in conexaoAPI.listaMotorista!!){
                if (cpf_formulario_abastecimento.text!!.toString() == i.cpf){
                    runOnUiThread {
                        nomeMotoristaHint.text = i.nomeCompleto
                    }
                }
            }
            
        }

    })

简单

int num  = 523;
String formatted = String.format("%011d", num);

改变

if (cpf_formulario_abastecimento.text!!.toString() == i.cpf){

至:

if (String.format("%011d", Integer(cpf_formulario_abastecimento.text!!.toString())) == i.cpf){