How to use addTextChangeListener in Kotlin with lambda expression?
Hello everyone! I just started learning Kotlin for Android development and trying to rewrite old Java code. Previously I added a text change listener to EditText like this:
```java
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// logic
}
@Override
public void afterTextChanged(Editable s) {
}
});
```
In Kotlin I'm trying to use a lambda but getting a compilation error. I tried something like:
```kotlin
editText.addTextChangedListener {
// want to handle onTextChanged here
}
```
But it doesn't work. I read that in Anko there are some...
No answers yet.
Log in to leave an answer
Blogs