I want to restrict the chars to 0-9, a-z, A-Z and spacebar only. Setting inputtype I can limit to digits but I cannot figure out the ways of Inputfilter looking through the
You can specify wanted characters in a regex and use it in InputFilter:
val regex = Regex("[a-zA-Z\\d ]") editText.filters = arrayOf(InputFilter { source, _, _, _, _, _ -> source.filter { regex.matches(it.toString()) } })
Notice, I didn't used \w character class, because it includes underscore _
\w
_