What's the best way to limit text length of EditText in Android

后端 未结 22 1904
囚心锁ツ
囚心锁ツ 2020-11-22 13:33

What\'s the best way to limit the text length of an EditText in Android?

Is there a way to do this via xml?

22条回答
  •  心在旅途
    2020-11-22 14:16

    Kotlin one-liner

    etxt_userinput.filters = arrayOf(InputFilter.LengthFilter(100))
    

    where 100 is the maxLength

提交回复
热议问题