0

hi i want set limit for my text edit in kotlin
please help...!

i want set 3 digit number for each of this inputs

        var num1=edt_no.text
        var num2=edt_ntw.text
        var num3=edt_nth.text
        var num4=edt_f.text
        when{
            edt_no.text.isEmpty() -> txt_res.text="First is empty"
            edt_ntw.text.isEmpty() -> txt_res.text="second is empty"
            edt_nth.text.isEmpty() -> txt_res.text="third is empty"
            edt_f.text.isEmpty() -> txt_res.text="Fourth is empty"
            else -> calc(num1,num2,num3,num4)
        }
  • 3
    Possible duplicate of [Limit text length of EditText in Android](https://stackoverflow.com/questions/3285412/limit-text-length-of-edittext-in-android) – Maroš Šeleng Nov 27 '18 at 19:30

1 Answers1

1

You need 2 attributes for each EditText:

android:maxLength="3"
android:inputType="number"
forpas
  • 160,666
  • 10
  • 38
  • 76