I would like to programmatically set maxLength
property of TextView
as I don\'t want to hard code it in the layout. I can\'t see any set
I made a simple extension function for this one
/**
* maxLength extension function makes a filter that
* will constrain edits not to make the length of the text
* greater than the specified length.
*
* @param max
*/
fun EditText.maxLength(max: Int){
this.filters = arrayOf(InputFilter.LengthFilter(max))
}
editText?.maxLength(10)