android 限制EditText输入内容为字母或汉字

val typeFilter = InputFilter { source, start, end, dest, dstart, dend ->
            val p = Pattern.compile("[a-zA-Z|\u4e00-\u9fa5]+")
            val m = p.matcher(source.toString())
            if (!m.matches()) "" else null
        }

        mName?.filters = arrayOf(typeFilter)
0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x