本文主要是介绍TextView addTextChangedListener Kotlin扩展函数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
fun TextView.addTextWatcher(beforeTextChanged: ((CharSequence?, Int, Int, Int) -> Unit)? = null,onTextChanged: ((CharSequence?, Int, Int, Int) -> Unit)? = null,afterTextChanged: ((Editable) -> Unit)? = null,
) {addTextChangedListener(object : TextWatcher {override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {beforeTextChanged?.invoke(s, start, count, after)}override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {onTextChanged?.invoke(s, start, before, count)}override fun afterTextChanged(s: Editable) {afterTextChanged?.invoke(s)}})}
使用
textView.addTextWatcher(afterTextChanged = { s ->})
这篇关于TextView addTextChangedListener Kotlin扩展函数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!