I need the user to type 11 digits but if he types less, zeros appear before the text typed.
Example:
11 digit text:
52396514262
If the user only enters 523:
I want the edit text to appear 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
}
}
}
}
})
2
Answers
Simply
Change
to: