pawegio / KAndroid

Kotlin library for Android
Apache License 2.0
894 stars 81 forks source link

Remove textwatcher listener #19

Closed brezinajn closed 7 years ago

brezinajn commented 7 years ago

Is there any way to remove listener added by textWatcher extension function? Thanks :)

pawegio commented 7 years ago

Hi @brezinajn, yes it's possible 🙂 You can access TextWatcher reference inside lambda and assign it to variable:

var textWatcher: TextWatcher? = null
textView.textWatcher {
    textWatcher = this
}
textView.removeTextChangedListener(textWatcher)
brezinajn commented 7 years ago

Uhm, missed that one :) Thanks :)