I want to set a filter to an edit text view.
view.findViewById<EditText>(R.id.some_edit_text).filters = arrayOf(object : InputFilter {
override fun filter(source: CharSequence?,
start: Int,
end: Int,
dest: Spanned?,
dstart: Int,
dend: Int): CharSequence {
// TODO: Do something
return "";
}
})
Anyways, Android Studio is showing me the following warning/suggestion for object : InputFilter.
Convert to Lambda
This inspection reports an anonymous object literal implementing a Java interface with a single abstract method that can be converted into a call with a lambda expression.
I know how to use lambda expressions for example to set on click listeners but how do I provide a single element array with implementing the interface with a lambda expression?